<A, E, R>(options: {
readonly acquire: Effect.Effect<A, E, R>
readonly size: number
readonly concurrency?: number | undefined
readonly targetUtilization?: number | undefined
}): Effect.Effect<Pool<A, E>, never, R | Scope.Scope>Makes a new pool of the specified fixed size.
When to use
Use when you need a fixed-size pool with no growth or shrinkage.
Details
The pool is returned in a Scope, which governs the lifetime of the pool.
When the pool is shutdown because the Scope is closed, the individual
items allocated by the pool will be released in some unspecified order.
By setting the concurrency parameter, you can control the level of concurrent
access per pool item. By default, the number of permits is set to 1.
targetUtilization determines when to create new pool items. It is a value
between 0 and 1, where 1 means only create new pool items when all the existing
items are fully utilized.
A targetUtilization of 0.5 will create new pool items when the existing items are
50% utilized.
export const const make: <A, E, R>(options: {
readonly acquire: Effect.Effect<A, E, R>
readonly size: number
readonly concurrency?: number | undefined
readonly targetUtilization?: number | undefined
}) => Effect.Effect<
Pool<A, E>,
never,
R | Scope.Scope
>
Makes a new pool of the specified fixed size.
When to use
Use when you need a fixed-size pool with no growth or shrinkage.
Details
The pool is returned in a Scope, which governs the lifetime of the pool.
When the pool is shutdown because the Scope is closed, the individual
items allocated by the pool will be released in some unspecified order.
By setting the concurrency parameter, you can control the level of concurrent
access per pool item. By default, the number of permits is set to 1.
targetUtilization determines when to create new pool items. It is a value
between 0 and 1, where 1 means only create new pool items when all the existing
items are fully utilized.
A targetUtilization of 0.5 will create new pool items when the existing items are
50% utilized.
make = <function (type parameter) A in <A, E, R>(options: {
readonly acquire: Effect.Effect<A, E, R>;
readonly size: number;
readonly concurrency?: number | undefined;
readonly targetUtilization?: number | undefined;
}): Effect.Effect<Pool<A, E>, never, R | Scope.Scope>
A, function (type parameter) E in <A, E, R>(options: {
readonly acquire: Effect.Effect<A, E, R>;
readonly size: number;
readonly concurrency?: number | undefined;
readonly targetUtilization?: number | undefined;
}): Effect.Effect<Pool<A, E>, never, R | Scope.Scope>
E, function (type parameter) R in <A, E, R>(options: {
readonly acquire: Effect.Effect<A, E, R>;
readonly size: number;
readonly concurrency?: number | undefined;
readonly targetUtilization?: number | undefined;
}): Effect.Effect<Pool<A, E>, never, R | Scope.Scope>
R>(options: {
readonly acquire: Effect.Effect<A, E, R>
readonly size: number
readonly concurrency?: number | undefined
readonly targetUtilization?: number | undefined
}
options: {
readonly acquire: Effect.Effect<A, E, R>(property) acquire: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
acquire: import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<function (type parameter) A in <A, E, R>(options: {
readonly acquire: Effect.Effect<A, E, R>;
readonly size: number;
readonly concurrency?: number | undefined;
readonly targetUtilization?: number | undefined;
}): Effect.Effect<Pool<A, E>, never, R | Scope.Scope>
A, function (type parameter) E in <A, E, R>(options: {
readonly acquire: Effect.Effect<A, E, R>;
readonly size: number;
readonly concurrency?: number | undefined;
readonly targetUtilization?: number | undefined;
}): Effect.Effect<Pool<A, E>, never, R | Scope.Scope>
E, function (type parameter) R in <A, E, R>(options: {
readonly acquire: Effect.Effect<A, E, R>;
readonly size: number;
readonly concurrency?: number | undefined;
readonly targetUtilization?: number | undefined;
}): Effect.Effect<Pool<A, E>, never, R | Scope.Scope>
R>
readonly size: numbersize: number
readonly concurrency?: number | undefinedconcurrency?: number | undefined
readonly targetUtilization?: number | undefinedtargetUtilization?: number | undefined
}): import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<interface Pool<in out A, in out E = never>A Pool<A, E> is a pool of items of type A, each of which may be
associated with the acquisition and release of resources. An attempt to get
an item A from a pool may fail with an error of type E.
When to use
Use when you need to share a bounded set of scoped resources across fibers
while the pool manages acquisition, reuse, and release.
Pool<function (type parameter) A in <A, E, R>(options: {
readonly acquire: Effect.Effect<A, E, R>;
readonly size: number;
readonly concurrency?: number | undefined;
readonly targetUtilization?: number | undefined;
}): Effect.Effect<Pool<A, E>, never, R | Scope.Scope>
A, function (type parameter) E in <A, E, R>(options: {
readonly acquire: Effect.Effect<A, E, R>;
readonly size: number;
readonly concurrency?: number | undefined;
readonly targetUtilization?: number | undefined;
}): Effect.Effect<Pool<A, E>, never, R | Scope.Scope>
E>, never, function (type parameter) R in <A, E, R>(options: {
readonly acquire: Effect.Effect<A, E, R>;
readonly size: number;
readonly concurrency?: number | undefined;
readonly targetUtilization?: number | undefined;
}): Effect.Effect<Pool<A, E>, never, R | Scope.Scope>
R | import ScopeScope.Scope> =>
const makeWithStrategy: <
A,
E,
R
>(options: {
readonly acquire: Effect.Effect<A, E, R>
readonly min: number
readonly max: number
readonly concurrency?: number | undefined
readonly targetUtilization?: number | undefined
readonly strategy: Strategy<A, E>
}) => Effect.Effect<
Pool<A, E>,
never,
Scope.Scope | R
>
Creates a scoped pool using a custom resizing and reclamation strategy.
When to use
Use to build a pool whose item lifecycle is controlled by an explicit
Strategy, such as custom background resizing, replacement, or reclamation.
Details
The returned pool requires Scope; closing the scope shuts down the pool and
releases allocated items.
makeWithStrategy({ ...options: {
readonly acquire: Effect.Effect<A, E, R>
readonly size: number
readonly concurrency?: number | undefined
readonly targetUtilization?: number | undefined
}
options, min: numbermin: options: {
readonly acquire: Effect.Effect<A, E, R>
readonly size: number
readonly concurrency?: number | undefined
readonly targetUtilization?: number | undefined
}
options.size: numbersize, max: numbermax: options: {
readonly acquire: Effect.Effect<A, E, R>
readonly size: number
readonly concurrency?: number | undefined
readonly targetUtilization?: number | undefined
}
options.size: numbersize, strategy: Strategy<A, E>(property) strategy: {
run: (pool: Pool<A, E>) => Effect.Effect<void>;
onAcquire: (item: PoolItem<A, E>) => Effect.Effect<void>;
reclaim: (pool: Pool<A, E>) => Effect.Effect<PoolItem<A, E> | undefined>;
}
strategy: const strategyNoop: <A, E>() => Strategy<
A,
E
>
strategyNoop() })