MCPcopy Create free account
hub / github.com/Effect-TS/effect / make

Function make

packages/sql/pglite/src/PgliteClient.ts:154–174  ·  view source on GitHub ↗
(
  options: PgliteClientConfig = {}
)

Source from the content-addressed store, hash-verified

152 * @since 4.0.0
153 */
154export const make = (
155 options: PgliteClientConfig = {}
156): Effect.Effect<PgliteClient, SqlError, Scope.Scope | Reactivity.Reactivity> =>
157 Effect.gen(function*() {
158 const pglite = "liveClient" in options
159 ? options.liveClient
160 : yield* Effect.acquireRelease(
161 Effect.tryPromise({
162 try: async () => {
163 const pg = new PGlite(options)
164 await pg.waitReady
165 return pg
166 },
167 catch: (cause) => new SqlError({ reason: classifyError(cause, "PgliteClient: Failed to connect", "connect") })
168 }),
169 (pg) => Effect.promise(() => pg.close()).pipe(Effect.timeoutOption(1000)),
170 { interruptible: true }
171 )
172
173 return yield* fromClient({ ...options, liveClient: pglite })
174 })
175
176/**
177 * Builds a `PgliteClient` around an existing PGlite instance, adding SQL client operations, LISTEN/NOTIFY, dump helpers, and serialized access.

Callers 2

layerConfigFunction · 0.70
layerFunction · 0.70

Calls 4

fromClientFunction · 0.85
classifyErrorFunction · 0.70
pipeMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected