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