Class IdRateLimiter
java.lang.Object
com.io7m.idstore.server.service.ratelimit.IdRateLimiter
- All Implemented Interfaces:
IdRateLimiterType
,com.io7m.repetoir.core.RPServiceType
A trivial rate limiter.
-
Method Summary
Modifier and TypeMethodDescriptionstatic IdRateLimiter
create
(IdMetricsServiceType metrics, String name, long expiration, TimeUnit timeUnit) Create a rate limiter.boolean
isAllowedByRateLimit
(String host, String user, String operation) toString()
waitTime()
-
Method Details
-
create
public static IdRateLimiter create(IdMetricsServiceType metrics, String name, long expiration, TimeUnit timeUnit) Create a rate limiter.- Parameters:
metrics
- The metrics servicename
- The rate nameexpiration
- The expiration for tokenstimeUnit
- The time unit for expirations- Returns:
- A rate limiter
-
isAllowedByRateLimit
- Parameters:
host
- The host performing the actionuser
- The user performing the actionoperation
- The operation- Returns:
true
if the given operation is allowed by rate limiting
-
toString
-
waitTime
- Specified by:
waitTime
in interfaceIdRateLimiterType
- Returns:
- The suggested wait time if a rate limit is exceeded
-
description
- Specified by:
description
in interfacecom.io7m.repetoir.core.RPServiceType
-