| 59 | } |
| 60 | |
| 61 | export class MysqlContainer extends Context.Tag("test/MysqlContainer")< |
| 62 | MysqlContainer, |
| 63 | StartedMySqlContainer |
| 64 | >() { |
| 65 | static Live = Layer.scoped( |
| 66 | this, |
| 67 | Effect.acquireRelease( |
| 68 | Effect.promise(() => new MySqlContainer("mysql:lts").start()), |
| 69 | (container) => Effect.promise(() => container.stop()) |
| 70 | ) |
| 71 | ) |
| 72 | |
| 73 | static ClientLive = Layer.unwrapEffect( |
| 74 | Effect.gen(function*() { |
| 75 | const container = yield* MysqlContainer |
| 76 | return Mysql.MysqlClient.layer({ |
| 77 | url: Redacted.make(container.getConnectionUri()) |
| 78 | }) |
| 79 | }) |
| 80 | ).pipe(Layer.provide(this.Live)) |
| 81 | } |