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

Function makeClient

packages/sql/pg/src/PgClient.ts:301–320  ·  view source on GitHub ↗
(
  options: PgClientConfig<R> & {
    /**
     * Opens a separate connection for each stream and listener when enabled.
     */
    readonly acquireForStream?: boolean | undefined
  }
)

Source from the content-addressed store, hash-verified

299 * @since 4.0.0
300 */
301export const makeClient = <R = never>(
302 options: PgClientConfig<R> & {
303 /**
304 * Opens a separate connection for each stream and listener when enabled.
305 */
306 readonly acquireForStream?: boolean | undefined
307 }
308): Effect.Effect<PgClient & Client.SqlClient, SqlError, Scope.Scope | Reactivity.Reactivity | R> =>
309 Effect.flatMap(PgConnection.make(options), (connection) =>
310 makeImpl({
311 acquirer: Effect.succeed(makeConnection(
312 connection,
313 options.acquireForStream ? PgConnection.make(options) : undefined
314 )),
315 transactionAcquirer: Effect.map(connection.pin, makeConnection),
316 listenAcquirer: options.acquireForStream ? PgConnection.make(options) : connection.pin,
317 config: options,
318 // The one session is leased for the client's lifetime.
319 poolStats: Effect.succeed({ idle: 0, used: 1, acquiring: 0, pending: 0, min: 1, max: 1 })
320 }))
321
322/**
323 * Builds the shared SQL facade around native connection acquirers.

Callers

nothing calls this directly

Calls 5

makeConnectionFunction · 0.85
makeMethod · 0.65
makeImplFunction · 0.50
succeedMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected