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.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      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 a CompletionStage representing 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 a CompletionStage representing 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 a CompletionStage representing 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 a CompletionStage representing 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 a CompletionStage representing 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 a CompletionStage representing 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 a CompletionStage representing the asynchronous computation of the task.
      ThreadPoolBulkheadConfig getBulkheadConfig()
      Returns the ThreadPoolBulkheadConfig of this Bulkhead.
      ThreadPoolBulkhead.ThreadPoolBulkheadEventPublisher getEventPublisher()
      Returns an EventPublisher which subscribes to the reactive stream of BulkheadEvent and can be used to register event consumers.
      ThreadPoolBulkhead.Metrics getMetrics()
      Get the Metrics of this Bulkhead.
      java.lang.String getName()
      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 ThreadPoolBulkhead of​(java.lang.String name, ThreadPoolBulkheadConfig config)
      Creates a bulkhead with a custom configuration
      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
      static ThreadPoolBulkhead of​(java.lang.String name, java.util.function.Supplier<ThreadPoolBulkheadConfig> bulkheadConfigSupplier)
      Creates a bulkhead with a custom configuration
      static ThreadPoolBulkhead ofDefaults​(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 a CompletionStage representing 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 a CompletionStage representing the asynchronous computation of the task.
      • Methods inherited from interface java.lang.AutoCloseable

        close
    • Method Detail

      • 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 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> 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 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 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 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​(java.lang.String name)
        Create a Bulkhead with a default configuration.
        Parameters:
        name - the name of the bulkhead
        Returns:
        a Bulkhead instance
      • of

        static ThreadPoolBulkhead of​(java.lang.String name,
                                     ThreadPoolBulkheadConfig config)
        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​(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 bulkhead
        config - 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 bulkhead
        bulkheadConfigSupplier - 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 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

        java.util.concurrent.CompletionStage<java.lang.Void> submit​(java.lang.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

        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
      • 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
      • 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 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> 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 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 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 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> java.util.concurrent.CompletionStage<T> executeSupplier​(java.util.function.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> java.util.concurrent.CompletionStage<T> executeCallable​(java.util.concurrent.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 java.util.concurrent.CompletionStage<java.lang.Void> executeRunnable​(java.lang.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