Package dev.failsafe

Class RateLimiterBuilder<R>

Type Parameters:
R - result type
All Implemented Interfaces:
PolicyListeners<RateLimiterBuilder<R>,R>

public class RateLimiterBuilder<R> extends PolicyBuilder<RateLimiterBuilder<R>,RateLimiterConfig<R>,R>
Builds RateLimiter instances.

This class is not threadsafe.

See Also:
  • Constructor Details

    • RateLimiterBuilder

      RateLimiterBuilder(Duration executionRate)
    • RateLimiterBuilder

      RateLimiterBuilder(long maxPermits, Duration period)
    • RateLimiterBuilder

      RateLimiterBuilder(RateLimiterConfig<R> config)
  • Method Details

    • build

      public RateLimiter<R> build()
      Builds a new RateLimiter using the builder's configuration.
    • withMaxWaitTime

      public RateLimiterBuilder<R> withMaxWaitTime(Duration maxWaitTime)
      Configures the maxWaitTime to wait for permits to be available. If permits cannot be acquired before the maxWaitTime is exceeded, then the rate limiter will throw RateLimitExceededException.

      This setting only applies when the resulting RateLimiter is used with the Failsafe class. It does not apply when the RateLimiter is used in a standalone way.

      Throws:
      NullPointerException - if maxWaitTime is null