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

Function makeWithTTL

packages/effect/src/Pool.ts:355–369  ·  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

353 * @since 2.0.0
354 */
355export const makeWithTTL = <A, E, R>(options: {
356 readonly acquire: Effect.Effect<A, E, R>
357 readonly min: number
358 readonly max: number
359 readonly concurrency?: number | undefined
360 readonly targetUtilization?: number | undefined
361 readonly timeToLive: Duration.Input
362 readonly timeToLiveStrategy?: "creation" | "usage" | undefined
363}): Effect.Effect<Pool<A, E>, never, R | Scope.Scope> =>
364 Effect.flatMap(
365 options.timeToLiveStrategy === "creation" ?
366 strategyCreationTTL<A, E>(options.timeToLive) :
367 strategyUsageTTL<A, E>(options.timeToLive),
368 (strategy) => makeWithStrategy({ ...options, strategy })
369 )
370
371/**
372 * 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