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 TokenBucketBuilderbuilder()Returns a newly createdTokenBucketBuilder.limits()Returns multiple limits applied to the bucket.static TokenBucketReturns a newly createdTokenBucketwith a single simpleBandwidthLimit.static TokenBucketReturns a newly createdTokenBucket.toString()
-
Method Details
-
builder
Returns a newly createdTokenBucketBuilder. -
of
Returns a newly createdTokenBucket. Computes a set ofBandwidthLimitout of a comma-separatedspecificationstring 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.]]specificationis 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 createdTokenBucketwith a single simpleBandwidthLimit. Specifies easy limitation oflimittokens perperiodtime 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
-