<K = unknown>(options: { readonly permits: number }): Effect.Effect<
PartitionedSemaphore<K>
>Creates a PartitionedSemaphore inside an Effect.
When to use
Use when semaphore construction should stay inside an Effect workflow.
Details
The permits option sets the shared permit capacity. The resulting
semaphore tracks waiters by partition key and distributes released permits
across waiting partitions in round-robin order.
Gotchas
Negative permit counts are clamped to 0. Non-finite permit counts create
an unbounded semaphore.
export const const make: <K = unknown>(options: {
readonly permits: number
}) => Effect.Effect<PartitionedSemaphore<K>>
Creates a PartitionedSemaphore inside an Effect.
When to use
Use when semaphore construction should stay inside an Effect workflow.
Details
The permits option sets the shared permit capacity. The resulting
semaphore tracks waiters by partition key and distributes released permits
across waiting partitions in round-robin order.
Gotchas
Negative permit counts are clamped to 0. Non-finite permit counts create
an unbounded semaphore.
make = <function (type parameter) K in <K = unknown>(options: {
readonly permits: number;
}): Effect.Effect<PartitionedSemaphore<K>>
K = unknown>(options: {
readonly permits: number
}
options: {
readonly permits: numberpermits: number
}): import EffectEffect.interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<interface PartitionedSemaphore<in K>A PartitionedSemaphore controls access to a shared permit pool while
tracking waiters by partition key.
When to use
Use to coordinate shared permits across partition keys so waiting groups make
progress without one group monopolizing the pool.
Details
Waiting permits are distributed across partitions in round-robin order.
PartitionedSemaphore<function (type parameter) K in <K = unknown>(options: {
readonly permits: number;
}): Effect.Effect<PartitionedSemaphore<K>>
K>> => import EffectEffect.const sync: <A>(
thunk: LazyArg<A>
) => Effect<A>
Creates an Effect that represents a synchronous side-effectful computation.
When to use
Use when you need to wrap a synchronous side-effectful operation that is not
expected to throw.
Details
The provided function is evaluated lazily when the effect runs.
Gotchas
The function must not throw. If it throws, the thrown value is treated as a
defect, not as a typed failure. Use try when throwing is expected.
Example (Capturing synchronous logging in an Effect)
import { Effect } from "effect"
const log = (message: string) =>
Effect.sync(() => {
console.log(message) // side effect
})
// ┌─── Effect<void, never, never>
// ▼
const program = log("Hello, World!")
sync(() => const makeUnsafe: <K = unknown>(options: {
readonly permits: number
}) => PartitionedSemaphore<K>
Constructs a PartitionedSemaphore synchronously, outside of Effect.
When to use
Use when you need to construct a partitioned semaphore synchronously outside
an Effect workflow.
Details
Negative permit counts are clamped to 0. Non-finite permit counts create
an unbounded semaphore whose acquire and release operations complete
immediately.
makeUnsafe<function (type parameter) K in <K = unknown>(options: {
readonly permits: number;
}): Effect.Effect<PartitionedSemaphore<K>>
K>(options: {
readonly permits: number
}
options))