R
- result typepublic interface Bulkhead<R> extends Policy<R>
This class is threadsafe.
BulkheadConfig
,
BulkheadBuilder
,
BulkheadFullException
Modifier and Type | Method and Description |
---|---|
void |
acquirePermit()
Attempts to acquire a permit to perform an execution against within the bulkhead, waiting until one is available or
the thread is interrupted.
|
default void |
acquirePermit(Duration maxWaitTime)
Attempts to acquire a permit to perform an execution within the bulkhead, waiting up to the
maxWaitTime
until one is available, else throwing BulkheadFullException if a permit will not be available in time. |
static <R> BulkheadBuilder<R> |
builder(BulkheadConfig<R> config)
Creates a new BulkheadBuilder that will be based on the
config . |
static <R> BulkheadBuilder<R> |
builder(int maxConcurrency)
Returns a Bulkhead for the
maxConcurrency that has zero
wait . |
BulkheadConfig<R> |
getConfig()
Returns the
BulkheadConfig that the Bulkhead was built with. |
static <R> Bulkhead<R> |
of(int maxConcurrency)
Returns a Bulkhead for the
maxConcurrency that has zero
wait . |
void |
releasePermit()
Releases a permit to execute.
|
boolean |
tryAcquirePermit()
Tries to acquire a permit to perform an execution within the bulkhead, returning immediately without waiting.
|
boolean |
tryAcquirePermit(Duration maxWaitTime)
Tries to acquire a permit to perform an execution within the bulkhead, waiting up to the
maxWaitTime until
they are available. |
toExecutor
static <R> BulkheadBuilder<R> builder(int maxConcurrency)
maxConcurrency
that has zero
wait
.maxConcurrency
- controls the max concurrent executions that are permitted within the bulkheadstatic <R> BulkheadBuilder<R> builder(BulkheadConfig<R> config)
config
.static <R> Bulkhead<R> of(int maxConcurrency)
maxConcurrency
that has zero
wait
. Alias for Bulkhead.builder(maxConcurrency).build()
. To configure additional options on a Bulkhead,
use builder(int)
instead.maxConcurrency
- controls the max concurrent executions that are permitted within the bulkheadbuilder(int)
BulkheadConfig<R> getConfig()
BulkheadConfig
that the Bulkhead was built with.void acquirePermit() throws InterruptedException
released
back
to the bulkhead.InterruptedException
- if the current thread is interrupted while waiting to acquire a permittryAcquirePermit()
default void acquirePermit(Duration maxWaitTime) throws InterruptedException
maxWaitTime
until one is available, else throwing BulkheadFullException
if a permit will not be available in time.
After execution is complete, the permit should be released
back to the bulkhead.NullPointerException
- if maxWaitTime
is nullBulkheadFullException
- if the bulkhead cannot acquire a permit within the maxWaitTime
InterruptedException
- if the current thread is interrupted while waiting to acquire a permittryAcquirePermit(Duration)
boolean tryAcquirePermit()
released
back to the bulkhead.permits
are successfully acquired or notboolean tryAcquirePermit(Duration maxWaitTime) throws InterruptedException
maxWaitTime
until
they are available. After execution is complete, the permit should be released
back to the
bulkhead.NullPointerException
- if maxWaitTime
is nullInterruptedException
- if the current thread is interrupted while waiting to acquire a permitvoid releasePermit()
Copyright © 2022. All rights reserved.