Class SemaphoreBulkhead
- java.lang.Object
-
- io.github.resilience4j.bulkhead.internal.SemaphoreBulkhead
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.github.resilience4j.bulkhead.Bulkhead
Bulkhead.BulkheadFuture<T>, Bulkhead.EventPublisher, Bulkhead.Metrics
-
-
Constructor Summary
Constructors Constructor Description SemaphoreBulkhead(java.lang.String name)Creates a bulkhead with a default config.SemaphoreBulkhead(java.lang.String name, BulkheadConfig bulkheadConfig)Creates a bulkhead using a configuration suppliedSemaphoreBulkhead(java.lang.String name, BulkheadConfig bulkheadConfig, io.vavr.collection.Map<java.lang.String,java.lang.String> tags)Creates a bulkhead using a configuration suppliedSemaphoreBulkhead(java.lang.String name, java.util.function.Supplier<BulkheadConfig> configSupplier)Create a bulkhead using a configuration supplierSemaphoreBulkhead(java.lang.String name, java.util.function.Supplier<BulkheadConfig> configSupplier, io.vavr.collection.Map<java.lang.String,java.lang.String> tags)Create a bulkhead using a configuration supplier
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacquirePermission()Acquires a permission to execute a call, only if one is available at the time of invocation If the current thread is interrupted while waiting for a permit then it won't throw InterruptedException, but its interrupt status will be set.voidchangeConfig(BulkheadConfig newConfig)Dynamic bulkhead configuration change.BulkheadConfiggetBulkheadConfig()Returns the BulkheadConfig of this Bulkhead.Bulkhead.EventPublishergetEventPublisher()Returns an EventPublisher which subscribes to the reactive stream of BulkheadEvent and can be used to register event consumers.Bulkhead.MetricsgetMetrics()Get the Metrics of this Bulkhead.java.lang.StringgetName()Returns the name of this bulkhead.io.vavr.collection.Map<java.lang.String,java.lang.String>getTags()Returns an unmodifiable map with tags assigned to this Bulkhead.voidonComplete()Records a completed call and releases a permission.voidreleasePermission()Releases a permission and increases the number of available permits by one.java.lang.StringtoString()booleantryAcquirePermission()Acquires a permission to execute a call, only if one is available at the time of invocation.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.github.resilience4j.bulkhead.Bulkhead
executeCallable, executeCheckedSupplier, executeCompletionStage, executeEitherSupplier, executeRunnable, executeSupplier, executeTrySupplier
-
-
-
-
Constructor Detail
-
SemaphoreBulkhead
public SemaphoreBulkhead(java.lang.String name, @Nullable BulkheadConfig bulkheadConfig)Creates a bulkhead using a configuration supplied- Parameters:
name- the name of this bulkheadbulkheadConfig- custom bulkhead configuration
-
SemaphoreBulkhead
public SemaphoreBulkhead(java.lang.String name, @Nullable BulkheadConfig bulkheadConfig, io.vavr.collection.Map<java.lang.String,java.lang.String> tags)Creates a bulkhead using a configuration supplied- Parameters:
name- the name of this bulkheadbulkheadConfig- custom bulkhead configurationtags- the tags to add to the Bulkhead
-
SemaphoreBulkhead
public SemaphoreBulkhead(java.lang.String name)
Creates a bulkhead with a default config.- Parameters:
name- the name of this bulkhead
-
SemaphoreBulkhead
public SemaphoreBulkhead(java.lang.String name, java.util.function.Supplier<BulkheadConfig> configSupplier)Create a bulkhead using a configuration supplier- Parameters:
name- the name of this bulkheadconfigSupplier- BulkheadConfig supplier
-
SemaphoreBulkhead
public SemaphoreBulkhead(java.lang.String name, java.util.function.Supplier<BulkheadConfig> configSupplier, io.vavr.collection.Map<java.lang.String,java.lang.String> tags)Create a bulkhead using a configuration supplier- Parameters:
name- the name of this bulkheadconfigSupplier- BulkheadConfig suppliertags- tags to add to the Bulkhead
-
-
Method Detail
-
changeConfig
public void changeConfig(BulkheadConfig newConfig)
Dynamic bulkhead configuration change. NOTE! New `maxWaitTime` duration won't affect threads that are currently waiting for permission.- Specified by:
changeConfigin interfaceBulkhead- Parameters:
newConfig- new BulkheadConfig
-
tryAcquirePermission
public boolean tryAcquirePermission()
Acquires a permission to execute a call, only if one is available at the time of invocation. If the current thread is interrupted while waiting for a permit then it won't throw InterruptedException, but its interrupt status will be set.- Specified by:
tryAcquirePermissionin interfaceBulkhead- Returns:
trueif a permission was acquired andfalseotherwise
-
acquirePermission
public void acquirePermission()
Acquires a permission to execute a call, only if one is available at the time of invocation If the current thread is interrupted while waiting for a permit then it won't throw InterruptedException, but its interrupt status will be set.- Specified by:
acquirePermissionin interfaceBulkhead
-
releasePermission
public void releasePermission()
Releases a permission and increases the number of available permits by one.Should only be used when a permission was acquired but not used. Otherwise use
Bulkhead.onComplete()to signal a completed call and release a permission.- Specified by:
releasePermissionin interfaceBulkhead
-
onComplete
public void onComplete()
Records a completed call and releases a permission.- Specified by:
onCompletein interfaceBulkhead
-
getName
public java.lang.String getName()
Returns the name of this bulkhead.
-
getBulkheadConfig
public BulkheadConfig getBulkheadConfig()
Returns the BulkheadConfig of this Bulkhead.- Specified by:
getBulkheadConfigin interfaceBulkhead- Returns:
- bulkhead config
-
getMetrics
public Bulkhead.Metrics getMetrics()
Get the Metrics of this Bulkhead.- Specified by:
getMetricsin interfaceBulkhead- Returns:
- the Metrics of this Bulkhead
-
getTags
public io.vavr.collection.Map<java.lang.String,java.lang.String> getTags()
Returns an unmodifiable map with tags assigned to this Bulkhead.
-
getEventPublisher
public Bulkhead.EventPublisher getEventPublisher()
Returns an EventPublisher which subscribes to the reactive stream of BulkheadEvent and can be used to register event consumers.- Specified by:
getEventPublisherin interfaceBulkhead- Returns:
- an EventPublisher
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-