Package io.github.resilience4j.bulkhead
Interface ThreadPoolBulkhead
- All Superinterfaces:
java.lang.AutoCloseable
- All Known Implementing Classes:
FixedThreadPoolBulkhead
public interface ThreadPoolBulkhead
extends java.lang.AutoCloseable
A Bulkhead instance is thread-safe can be used to decorate multiple requests.
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceThreadPoolBulkhead.Metricsstatic interfaceThreadPoolBulkhead.ThreadPoolBulkheadEventPublisherAn EventPublisher which can be used to register event consumers. -
Method Summary
Modifier and Type Method Description static <T> java.util.function.Supplier<java.util.concurrent.CompletionStage<T>>decorateCallable(ThreadPoolBulkhead bulkhead, java.util.concurrent.Callable<T> callable)Returns a supplier which submits a value-returning task for execution and returns aCompletionStagerepresenting the pending results of the task.default <T> java.util.function.Supplier<java.util.concurrent.CompletionStage<T>>decorateCallable(java.util.concurrent.Callable<T> callable)Returns a supplier which submits a value-returning task for execution and returns a CompletionStage representing the asynchronous computation of the task.static java.util.function.Supplier<java.util.concurrent.CompletionStage<java.lang.Void>>decorateRunnable(ThreadPoolBulkhead bulkhead, java.lang.Runnable runnable)Returns a supplier which submits a task for execution and returns aCompletionStagerepresenting the state of the task.default java.util.function.Supplier<java.util.concurrent.CompletionStage<java.lang.Void>>decorateRunnable(java.lang.Runnable runnable)Returns a supplier which submits a task for execution and returns aCompletionStagerepresenting the asynchronous computation of the task.static <T> java.util.function.Supplier<java.util.concurrent.CompletionStage<T>>decorateSupplier(ThreadPoolBulkhead bulkhead, java.util.function.Supplier<T> supplier)Returns a supplier which submits a value-returning task for execution and returns aCompletionStagerepresenting the pending results of the task.default <T> java.util.function.Supplier<java.util.concurrent.CompletionStage<T>>decorateSupplier(java.util.function.Supplier<T> supplier)Returns a supplier which submits a value-returning task for execution and returns a CompletionStage representing the asynchronous computation of the task.default <T> java.util.concurrent.CompletionStage<T>executeCallable(java.util.concurrent.Callable<T> callable)Submits a value-returning task for execution and returns aCompletionStagerepresenting the asynchronous computation of the task.default java.util.concurrent.CompletionStage<java.lang.Void>executeRunnable(java.lang.Runnable runnable)Submits a task for execution and returns aCompletionStagerepresenting the asynchronous computation of the task.default <T> java.util.concurrent.CompletionStage<T>executeSupplier(java.util.function.Supplier<T> supplier)Submits a value-returning task for execution and returns aCompletionStagerepresenting the asynchronous computation of the task.ThreadPoolBulkheadConfiggetBulkheadConfig()Returns the ThreadPoolBulkheadConfig of this Bulkhead.ThreadPoolBulkhead.ThreadPoolBulkheadEventPublishergetEventPublisher()Returns an EventPublisher which subscribes to the reactive stream of BulkheadEvent and can be used to register event consumers.ThreadPoolBulkhead.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 Retry.static ThreadPoolBulkheadof(java.lang.String name, ThreadPoolBulkheadConfig config)Creates a bulkhead with a custom configurationstatic ThreadPoolBulkheadof(java.lang.String name, ThreadPoolBulkheadConfig config, io.vavr.collection.Map<java.lang.String,java.lang.String> tags)Creates a bulkhead with a custom configurationstatic ThreadPoolBulkheadof(java.lang.String name, java.util.function.Supplier<ThreadPoolBulkheadConfig> bulkheadConfigSupplier)Creates a bulkhead with a custom configurationstatic ThreadPoolBulkheadofDefaults(java.lang.String name)Create a Bulkhead with a default configuration.java.util.concurrent.CompletionStage<java.lang.Void>submit(java.lang.Runnable task)Submits a task for execution to the ThreadPoolBulkhead and returns aCompletionStagerepresenting the asynchronous computation of the task.<T> java.util.concurrent.CompletionStage<T>submit(java.util.concurrent.Callable<T> task)Submits a value-returning task for execution and returns aCompletionStagerepresenting the asynchronous computation of the task.
-
Method Details
-
decorateCallable
static <T> java.util.function.Supplier<java.util.concurrent.CompletionStage<T>> decorateCallable(ThreadPoolBulkhead bulkhead, java.util.concurrent.Callable<T> callable)Returns a supplier which submits a value-returning task for execution and returns aCompletionStagerepresenting the pending results of the task. The Supplier throws aBulkheadFullExceptionif the task cannot be submitted, because the Bulkhead is full.- Type Parameters:
T- the result type of the callable- Parameters:
bulkhead- the bulkheadcallable- the value-returning task to submit- Returns:
- a supplier which submits a value-returning task for execution and returns a CompletionStage representing the pending results of the task
-
decorateSupplier
static <T> java.util.function.Supplier<java.util.concurrent.CompletionStage<T>> decorateSupplier(ThreadPoolBulkhead bulkhead, java.util.function.Supplier<T> supplier)Returns a supplier which submits a value-returning task for execution and returns aCompletionStagerepresenting the pending results of the task. The Supplier throws aBulkheadFullExceptionif the task cannot be submitted, because the Bulkhead is full.- Type Parameters:
T- the result type of the supplier- Parameters:
bulkhead- the bulkheadsupplier- the value-returning task to submit- Returns:
- a supplier which submits a value-returning task for execution and returns a CompletionStage representing the pending results of the task
-
decorateRunnable
static java.util.function.Supplier<java.util.concurrent.CompletionStage<java.lang.Void>> decorateRunnable(ThreadPoolBulkhead bulkhead, java.lang.Runnable runnable)Returns a supplier which submits a task for execution and returns aCompletionStagerepresenting the state of the task. The Supplier throws aBulkheadFullExceptionif the task cannot be submitted, because the Bulkhead is full.- Parameters:
bulkhead- the bulkheadrunnable- the to submit- Returns:
- a supplier which submits a task for execution to the ThreadPoolBulkhead and returns a CompletionStage representing the state of the task
-
ofDefaults
Create a Bulkhead with a default configuration.- Parameters:
name- the name of the bulkhead- Returns:
- a Bulkhead instance
-
of
Creates a bulkhead with a custom configuration- Parameters:
name- the name of the bulkheadconfig- a custom BulkheadConfig configuration- Returns:
- a Bulkhead instance
-
of
static ThreadPoolBulkhead of(java.lang.String name, ThreadPoolBulkheadConfig config, io.vavr.collection.Map<java.lang.String,java.lang.String> tags)Creates a bulkhead with a custom configuration- Parameters:
name- the name of the bulkheadconfig- a custom BulkheadConfig configuration- Returns:
- a Bulkhead instance
-
of
static ThreadPoolBulkhead of(java.lang.String name, java.util.function.Supplier<ThreadPoolBulkheadConfig> bulkheadConfigSupplier)Creates a bulkhead with a custom configuration- Parameters:
name- the name of the bulkheadbulkheadConfigSupplier- custom configuration supplier- Returns:
- a Bulkhead instance
-
submit
<T> java.util.concurrent.CompletionStage<T> submit(java.util.concurrent.Callable<T> task)Submits a value-returning task for execution and returns aCompletionStagerepresenting the asynchronous computation of the task.- Type Parameters:
T- the type of the task's result- Parameters:
task- the value-returning task to submit- Returns:
- CompletionStage representing the asynchronous computation of the task. The CompletionStage is completed exceptionally with a
BulkheadFullExceptionwhen the task could not be submitted, because the Bulkhead was full - Throws:
BulkheadFullException- if the task cannot be submitted, because the Bulkhead is full
-
submit
java.util.concurrent.CompletionStage<java.lang.Void> submit(java.lang.Runnable task)Submits a task for execution to the ThreadPoolBulkhead and returns aCompletionStagerepresenting the asynchronous computation of the task.- Parameters:
task- the task to submit- Returns:
- CompletionStage representing the asynchronous computation of the task.
- Throws:
BulkheadFullException- if the task cannot be submitted, because the Bulkhead is full
-
getName
java.lang.String getName()Returns the name of this bulkhead.- Returns:
- the name of this bulkhead
-
getBulkheadConfig
ThreadPoolBulkheadConfig getBulkheadConfig()Returns the ThreadPoolBulkheadConfig of this Bulkhead.- Returns:
- bulkhead config
-
getMetrics
ThreadPoolBulkhead.Metrics getMetrics()Get the Metrics of this Bulkhead.- Returns:
- the Metrics of this Bulkhead
-
getTags
io.vavr.collection.Map<java.lang.String,java.lang.String> getTags()Returns an unmodifiable map with tags assigned to this Retry.- Returns:
- the tags assigned to this Retry in an unmodifiable map
-
getEventPublisher
ThreadPoolBulkhead.ThreadPoolBulkheadEventPublisher getEventPublisher()Returns an EventPublisher which subscribes to the reactive stream of BulkheadEvent and can be used to register event consumers.- Returns:
- an EventPublisher
-
decorateSupplier
default <T> java.util.function.Supplier<java.util.concurrent.CompletionStage<T>> decorateSupplier(java.util.function.Supplier<T> supplier)Returns a supplier which submits a value-returning task for execution and returns a CompletionStage representing the asynchronous computation of the task. The Supplier throws aBulkheadFullExceptionif the task cannot be submitted, because the Bulkhead is full.- Type Parameters:
T- the result type of the callable- Parameters:
supplier- the value-returning task to submit- Returns:
- a supplier which submits a value-returning task for execution and returns a CompletionStage representing the asynchronous computation of the task
-
decorateCallable
default <T> java.util.function.Supplier<java.util.concurrent.CompletionStage<T>> decorateCallable(java.util.concurrent.Callable<T> callable)Returns a supplier which submits a value-returning task for execution and returns a CompletionStage representing the asynchronous computation of the task. The Supplier throws aBulkheadFullExceptionif the task cannot be submitted, because the Bulkhead is full.- Type Parameters:
T- the result type of the callable- Parameters:
callable- the value-returning task to submit- Returns:
- a supplier which submits a value-returning task for execution and returns a CompletionStage representing the asynchronous computation of the task
-
decorateRunnable
default java.util.function.Supplier<java.util.concurrent.CompletionStage<java.lang.Void>> decorateRunnable(java.lang.Runnable runnable)Returns a supplier which submits a task for execution and returns aCompletionStagerepresenting the asynchronous computation of the task. The Supplier throws aBulkheadFullExceptionif the task cannot be submitted, because the Bulkhead is full.- Parameters:
runnable- the task to submit- Returns:
- a supplier which submits a task for execution and returns a CompletionStage representing the asynchronous computation of the task
-
executeSupplier
default <T> java.util.concurrent.CompletionStage<T> executeSupplier(java.util.function.Supplier<T> supplier)Submits a value-returning task for execution and returns aCompletionStagerepresenting the asynchronous computation of the task.- Type Parameters:
T- the type of the task's result- Parameters:
supplier- the value-returning task to submit- Returns:
- a CompletionStage representing the asynchronous computation of the task.
- Throws:
BulkheadFullException- if the task cannot be submitted, because the Bulkhead is full
-
executeCallable
default <T> java.util.concurrent.CompletionStage<T> executeCallable(java.util.concurrent.Callable<T> callable)Submits a value-returning task for execution and returns aCompletionStagerepresenting the asynchronous computation of the task.- Type Parameters:
T- the result type of the Callable- Parameters:
callable- the value-returning task to submit- Returns:
- a
CompletionStagerepresenting the asynchronous computation of the task. - Throws:
BulkheadFullException- if the task cannot be submitted, because the Bulkhead is full
-
executeRunnable
default java.util.concurrent.CompletionStage<java.lang.Void> executeRunnable(java.lang.Runnable runnable)Submits a task for execution and returns aCompletionStagerepresenting the asynchronous computation of the task.- Parameters:
runnable- the task to submit- Returns:
- CompletionStage representing the asynchronous computation of the task.
- Throws:
BulkheadFullException- if the task cannot be submitted, because the Bulkhead is full
-