Bulkhead

interface Bulkhead

A Bulkhead can be used to limit the number of concurrent executions.

It maintains a fixed-size pool of permits. A caller must acquire a permit to execute an operation. If a permit is available, it is acquired, and the operation is executed. If no permits are available, the caller may be queued up to a configurable limit (maxWaitingCalls). Once a permit is released, a queued caller is dequeued and allowed to execute. If the queue is full, further calls will be rejected immediately with a BulkheadFullException.

This pattern is useful for protecting resources from being overloaded by too many concurrent requests.

See also

for configuration options.

Inheritors

Functions

Link copied to clipboard
abstract suspend fun <T> execute(block: suspend () -> T): T

Acquires a permit (or queues), executes block, then releases the permit.

Link copied to clipboard

Returns a point-in-time snapshot of bulkhead usage for health/readiness and metrics. Implementations that support it return a BulkheadSnapshot; others may return null.