Class BulkheadConfig.Builder

  • Enclosing class:
    BulkheadConfig

    public static class BulkheadConfig.Builder
    extends java.lang.Object
    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • maxConcurrentCalls

        public BulkheadConfig.Builder maxConcurrentCalls​(int maxConcurrentCalls)
        Configures the max amount of concurrent calls the bulkhead will support.
        Parameters:
        maxConcurrentCalls - max concurrent calls
        Returns:
        the BulkheadConfig.Builder
      • maxWaitDuration

        public BulkheadConfig.Builder maxWaitDuration​(java.time.Duration maxWaitDuration)
        Configures a maximum amount of time which the calling thread will wait to enter the bulkhead. If bulkhead has space available, entry is guaranteed and immediate. If bulkhead is full, calling threads will contest for space, if it becomes available. maxWaitDuration can be set to 0.

        Note: for threads running on an event-loop or equivalent (rx computation pool, etc), setting maxWaitDuration to 0 is highly recommended. Blocking an event-loop thread will most likely have a negative effect on application throughput.

        Parameters:
        maxWaitDuration - maximum wait time for bulkhead entry
        Returns:
        the BulkheadConfig.Builder
      • writableStackTraceEnabled

        public BulkheadConfig.Builder writableStackTraceEnabled​(boolean writableStackTraceEnabled)
        Enables writable stack traces. When set to false, Throwable.getStackTrace() returns a zero length array. This may be used to reduce log spam when the circuit breaker is open as the cause of the exceptions is already known (the circuit breaker is short-circuiting calls).
        Parameters:
        writableStackTraceEnabled - flag to control if stack trace is writable
        Returns:
        the BulkheadConfig.Builder
      • fairCallHandlingStrategyEnabled

        public BulkheadConfig.Builder fairCallHandlingStrategyEnabled​(boolean fairCallHandlingEnabled)
        Indicates whether FairSync or NonfairSync should be used in Semaphore. When set to true, a fair call handling strategy is used. It guarantees the order of incoming requests (FIFO) based on internal queue. When set to false, an non fair strategy will be used which does not guarantee any order of calls.
        Parameters:
        fairCallHandlingEnabled - flag to choose call handling strategy between fair and unfair
        Returns:
        the BulkheadConfig.Builder
      • build

        public BulkheadConfig build()
        Builds a BulkheadConfig
        Returns:
        the BulkheadConfig