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) long
maxPermits
(package private) java.time.Duration
maxRate
(package private) java.time.Duration
maxWaitTime
(package private) java.time.Duration
period
-
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 long
getMaxPermits()
For bursty rate limiters, returns the max permitted executions perperiod
, elsenull
if the rate limiter is not bursty.java.time.Duration
getMaxRate()
For smooth rate limiters, returns the max rate at which individual executions are permitted, elsenull
if the rate limiter is not smooth.java.time.Duration
getMaxWaitTime()
Returns the max time to wait for permits to be available.java.time.Duration
getPeriod()
For bursty rate limiters, returns the period after which permits are reset tomaxPermits
, elsenull
if 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, elsenull
if the rate limiter is not smooth.
-
getMaxPermits
public long getMaxPermits()
For bursty rate limiters, returns the max permitted executions perperiod
, elsenull
if 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
, elsenull
if 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
Failsafe
class. It does not apply when the RateLimiter is used in a standalone way.
-
-