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

Function makeWithTTL

packages/effect/src/Pool.ts:287–301  ·  view source on GitHub ↗
(options: {
  readonly acquire: Effect.Effect<A, E, R>
  readonly min: number
  readonly max: number
  readonly concurrency?: number | undefined
  readonly targetUtilization?: number | undefined
  readonly timeToLive: Duration.Input
  readonly timeToLiveStrategy?: "creation" | "usage" | undefined
})

Source from the content-addressed store, hash-verified

285 * @since 2.0.0
286 */
287export const makeWithTTL = <A, E, R>(options: {
288 readonly acquire: Effect.Effect<A, E, R>
289 readonly min: number
290 readonly max: number
291 readonly concurrency?: number | undefined
292 readonly targetUtilization?: number | undefined
293 readonly timeToLive: Duration.Input
294 readonly timeToLiveStrategy?: "creation" | "usage" | undefined
295}): Effect.Effect<Pool<A, E>, never, R | Scope.Scope> =>
296 Effect.flatMap(
297 options.timeToLiveStrategy === "creation" ?
298 strategyCreationTTL<A, E>(options.timeToLive) :
299 strategyUsageTTL<A, E>(options.timeToLive),
300 (strategy) => makeWithStrategy({ ...options, strategy })
301 )
302
303/**
304 * Creates a scoped pool using a custom resizing and reclamation strategy.

Callers

nothing calls this directly

Calls 1

makeWithStrategyFunction · 0.85

Tested by

no test coverage detected