MCPcopy Create free account
hub / github.com/effect-app/libs / LibsqlContainer

Class LibsqlContainer

repos/effect/packages/sql/libsql/test/util.ts:22–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20}
21
22export class LibsqlContainer extends Context.Service<
23 LibsqlContainer,
24 StartedTestContainer
25>()("test/LibsqlContainer") {
26 static readonly layer = Layer.effect(this)(
27 Effect.acquireRelease(
28 Effect.promise(async () => {
29 const container = await new GenericContainer("ghcr.io/tursodatabase/libsql-server:main")
30 .withExposedPorts(8080)
31 .withEnvironment({ SQLD_NODE: "primary" })
32 .withCommand(["sqld", "--no-welcome", "--http-listen-addr", "0.0.0.0:8080"]).start()
33
34 try {
35 await waitForServer(container)
36 return container
37 } catch (error) {
38 await container.stop()
39 throw error
40 }
41 }),
42 (container) => Effect.promise(() => container.stop())
43 )
44 )
45
46 static layerClient = Layer.unwrap(
47 Effect.gen(function*() {
48 const container = yield* LibsqlContainer
49 return LibsqlClient.layer({
50 url: `http://${container.getHost()}:${container.getMappedPort(8080)}`
51 })
52 })
53 ).pipe(Layer.provide(this.layer))
54}

Callers

nothing calls this directly

Calls 3

waitForServerFunction · 0.85
pipeMethod · 0.65
provideMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…