Interface ThreadPoolBulkhead

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
FixedThreadPoolBulkhead

public interface ThreadPoolBulkhead extends AutoCloseable
A Bulkhead instance is thread-safe can be used to decorate multiple requests.
  • Method Details

    • decorateCallable

      static <T> Supplier<CompletionStage<T>> decorateCallable(ThreadPoolBulkhead bulkhead, Callable<T> callable)
      Returns a supplier which submits a value-returning task for execution and returns a CompletionStage representing the pending results of the task. The Supplier throws a BulkheadFullException if the task cannot be submitted, because the Bulkhead is full.
      Type Parameters:
      T - the result type of the callable
      Parameters:
      bulkhead - the bulkhead
      callable - 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> Supplier<CompletionStage<T>> decorateSupplier(ThreadPoolBulkhead bulkhead, Supplier<T> supplier)
      Returns a supplier which submits a value-returning task for execution and returns a CompletionStage representing the pending results of the task. The Supplier throws a BulkheadFullException if the task cannot be submitted, because the Bulkhead is full.
      Type Parameters:
      T - the result type of the supplier
      Parameters:
      bulkhead - the bulkhead
      supplier - 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 Supplier<CompletionStage<Void>> decorateRunnable(ThreadPoolBulkhead bulkhead, Runnable runnable)
      Returns a supplier which submits a task for execution and returns a CompletionStage representing the state of the task. The Supplier throws a BulkheadFullException if the task cannot be submitted, because the Bulkhead is full.
      Parameters:
      bulkhead - the bulkhead
      runnable - 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

      static ThreadPoolBulkhead ofDefaults(String name)
      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 bulkhead
      config - a custom BulkheadConfig configuration
      Returns:
      a Bulkhead instance
    • of

      Creates a bulkhead with a custom configuration
      Parameters:
      name - the name of the bulkhead
      config - a custom BulkheadConfig configuration
      Returns:
      a Bulkhead instance
    • of

      static ThreadPoolBulkhead of(String name, Supplier<ThreadPoolBulkheadConfig> bulkheadConfigSupplier)
      Creates a bulkhead with a custom configuration
      Parameters:
      name - the name of the bulkhead
      bulkheadConfigSupplier - custom configuration supplier
      Returns:
      a Bulkhead instance
    • submit

      <T> CompletionStage<T> submit(Callable<T> task)
      Submits a value-returning task for execution and returns a CompletionStage representing 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 BulkheadFullException when 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

      CompletionStage<Void> submit(Runnable task)
      Submits a task for execution to the ThreadPoolBulkhead and returns a CompletionStage representing 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

      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

      Get the Metrics of this Bulkhead.
      Returns:
      the Metrics of this Bulkhead
    • getTags

      Map<String,String> getTags()
      Returns an unmodifiable map with tags assigned to this Retry.
      Returns:
      the tags assigned to this Retry in an unmodifiable map
    • 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> Supplier<CompletionStage<T>> decorateSupplier(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 a BulkheadFullException if 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> Supplier<CompletionStage<T>> decorateCallable(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 a BulkheadFullException if 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 Supplier<CompletionStage<Void>> decorateRunnable(Runnable runnable)
      Returns a supplier which submits a task for execution and returns a CompletionStage representing the asynchronous computation of the task. The Supplier throws a BulkheadFullException if 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> CompletionStage<T> executeSupplier(Supplier<T> supplier)
      Submits a value-returning task for execution and returns a CompletionStage representing 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> CompletionStage<T> executeCallable(Callable<T> callable)
      Submits a value-returning task for execution and returns a CompletionStage representing 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 CompletionStage representing the asynchronous computation of the task.
      Throws:
      BulkheadFullException - if the task cannot be submitted, because the Bulkhead is full
    • executeRunnable

      default CompletionStage<Void> executeRunnable(Runnable runnable)
      Submits a task for execution and returns a CompletionStage representing 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