Class TokenBucket
java.lang.Object
com.linecorp.armeria.server.throttling.bucket4j.TokenBucket
Stores configuration of the Token-Bucket algorithm, comprised of multiple limits.
-
Method Summary
Modifier and TypeMethodDescriptionstatic TokenBucketBuilder
builder()
Returns a newly createdTokenBucketBuilder
.limits()
Returns multiple limits applied to the bucket.static TokenBucket
Returns a newly createdTokenBucket
with a single simpleBandwidthLimit
.static TokenBucket
Returns a newly createdTokenBucket
.toString()
-
Method Details
-
builder
Returns a newly createdTokenBucketBuilder
. -
of
Returns a newly createdTokenBucket
. Computes a set ofBandwidthLimit
out of a comma-separatedspecification
string that conforms to the following format, as per RateLimit Header Fields for HTTP:
The order of elements inside<bandwidth limit 1>[, <bandwidth limit 2>[, etc.]]
specification
is not defined. For example:100;window=60;burst=1000, 50000;window=3600
- Parameters:
specification
- the specification used to create aBandwidthLimit
- See Also:
-
TokenBucketSpec.parseTokenBucket(String)
-
of
Returns a newly createdTokenBucket
with a single simpleBandwidthLimit
. Specifies easy limitation oflimit
tokens perperiod
time window.- Parameters:
limit
- the bucket size - defines the maximum count of tokens which can be held by the bucket and defines the speed at which tokens are regenerated in the bucketperiod
- the time window, during which the tokens will be regenerated- Returns:
- Newly created
TokenBucket
- See Also:
-
limits
Returns multiple limits applied to the bucket. This may be empty.- Returns:
- An array of
BandwidthLimit
-
toString
-