Package dev.failsafe
Class RateLimiterConfig<R>
- java.lang.Object
-
- dev.failsafe.PolicyConfig<R>
-
- dev.failsafe.RateLimiterConfig<R>
-
- Type Parameters:
R- result type
public class RateLimiterConfig<R> extends PolicyConfig<R>
Configuration for aRateLimiter.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) longmaxPermits(package private) java.time.DurationmaxRate(package private) java.time.DurationmaxWaitTime(package private) java.time.Durationperiod-
Fields inherited from class dev.failsafe.PolicyConfig
failureListener, successListener
-
-
Constructor Summary
Constructors Constructor Description RateLimiterConfig(long maxPermits, java.time.Duration period)RateLimiterConfig(RateLimiterConfig<R> config)RateLimiterConfig(java.time.Duration maxRate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetMaxPermits()For bursty rate limiters, returns the max permitted executions perperiod, elsenullif the rate limiter is not bursty.java.time.DurationgetMaxRate()For smooth rate limiters, returns the max rate at which individual executions are permitted, elsenullif the rate limiter is not smooth.java.time.DurationgetMaxWaitTime()Returns the max time to wait for permits to be available.java.time.DurationgetPeriod()For bursty rate limiters, returns the period after which permits are reset tomaxPermits, elsenullif the rate limiter is not bursty.-
Methods inherited from class dev.failsafe.PolicyConfig
getFailureListener, getSuccessListener
-
-
-
-
Constructor Detail
-
RateLimiterConfig
RateLimiterConfig(java.time.Duration maxRate)
-
RateLimiterConfig
RateLimiterConfig(long maxPermits, java.time.Duration period)
-
RateLimiterConfig
RateLimiterConfig(RateLimiterConfig<R> config)
-
-
Method Detail
-
getMaxRate
public java.time.Duration getMaxRate()
For smooth rate limiters, returns the max rate at which individual executions are permitted, elsenullif the rate limiter is not smooth.
-
getMaxPermits
public long getMaxPermits()
For bursty rate limiters, returns the max permitted executions perperiod, elsenullif the rate limiter is not bursty.
-
getPeriod
public java.time.Duration getPeriod()
For bursty rate limiters, returns the period after which permits are reset tomaxPermits, elsenullif the rate limiter is not bursty.
-
getMaxWaitTime
public java.time.Duration getMaxWaitTime()
Returns the max time to wait for permits to be available. If permits cannot be acquired before the max wait time is exceeded, then the rate limiter will throwRateLimitExceededException.This setting only applies when the RateLimiter is used with the
Failsafeclass. It does not apply when the RateLimiter is used in a standalone way.
-
-