DefaultBulkhead
A semaphore-based implementation of the Bulkhead pattern.
This implementation controls the number of concurrent executions and the number of calls waiting to be executed. It uses a Semaphore to limit the number of parallel executions to [BulkheadConfig.maxConcurrentCalls].
When all permits of the semaphore are acquired, incoming calls are placed in a waiting queue. The size of this queue is limited by [BulkheadConfig.maxWaitingCalls]. If the queue is also full, any new calls will be rejected immediately with a BulkheadFullException.
A call waiting in the queue will attempt to acquire a permit from the semaphore. If a [BulkheadConfig.timeout] is configured, the call will wait for the specified duration. If it fails to acquire a permit within this time, it is rejected.
Parameters
The BulkheadConfig used to configure this instance.
Optional callback invoked synchronously when a call is rejected before throwing BulkheadFullException. Receives a human-readable reason string. Used for telemetry (e.g. emitting com.santimattius.resilient.telemetry.ResilientEvent.BulkheadRejected) regardless of whether a Fallback policy is configured.
Functions
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.