A function literal with receiver, used for specifying SuspendingBucket configuration.
diff --git a/bucket4k/com.sletmoe.bucket4k/-suspending-bucket-configuration/-suspending-bucket-configuration.html b/bucket4k/com.sletmoe.bucket4k/-suspending-bucket-configuration/-suspending-bucket-configuration.html index 8be77ac..25766db 100644 --- a/bucket4k/com.sletmoe.bucket4k/-suspending-bucket-configuration/-suspending-bucket-configuration.html +++ b/bucket4k/com.sletmoe.bucket4k/-suspending-bucket-configuration/-suspending-bucket-configuration.html @@ -40,7 +40,7 @@
Adds a bandwidth limit to the bucket. See the Bucket4j documentation on Bandwidths for more information.
Set's the TimeMeter to be used by the underlying Bucket4j objects. By default, you may choose either TimeMeter.SYSTEM_MILLISECONDS or TimeMeter.SYSTEM_NANOSECONDS. Caution: see Bucket4j's documentation about using nanoseconds before choosing that option.
A type-safe builder for constructing SuspendingBucket objects.
A SuspendingBucket, constructed with the specified configuration.
A function literal with receiver, used for specifying SuspendingBucket configuration.
Adds the specified number of tokensToAdd to the bucket, not exceeding the capacity of the bucket. Delegates directly to the underlying LockFreeBucket's addTokens implementation.
The number of tokens to add to the bucket.
Returns the number of currently available tokens. Delegates directly to the underlying LockFreeBucket's getAvailableTokens implementation.
Returns the Bucket4j BucketConfiguration of the underlying LockFreeBucket. Delegates directly to the underlying LockFreeBucket's getConfiguration implementation.
Consumes the specified number of tokensToConsume, suspending as long as necessary to accumulate the requisite number of tokens. This algorithm is a direct copy of Bucket4j BlockingBucket's consume, except it suspends the calling coroutine's execution while waiting for available tokens, rather than blocking the thread. See the Bucket4j consume documentation for more details.
The number of tokens to try and consume from the bucket. Must be a positive value.
Adds the specified number of tokensToAdd to the bucket, even if it would result in the bucket containing more than its specified capacity. Delegates directly to the underlying LockFreeBucket's forceAddTokens implementation.
The number of tokens to add to the bucket.
Replaces the bucket's configuration. This delegates directly to the underlying LockFreeBucket's replaceConfiguration implementation.
The inheritance strategy is complex enough that I'm not going to summarize the algorithm here, see Bucket4j's documentation for more information.
The new BucketConfiguration to use.
Configuration for the strategy to use for token inheritance.
Tries to consume the specified number of tokensToConsume. Delegates directly to the underlying LockFreeBucket's tryConsume implementation.
true if the tokens were consumed, false otherwise.
The number of tokens to try and consume from the bucket. Must be a positive value.
Tries to consume the specified number of tokensToConsume, suspending up to maxWaitTime if necessary in order to accumulate enough tokens to consume the specified amount.
The (slightly simplified) logic is as follows:
if tokensToConsume tokens are available, consume them and return true immediately
else if enough tokens will be made available to satisfy tokensToConsume within maxWaitTime, the function will delay until the requisite number of tokens are available, consume them, and return true.
else, will immediately return false.
It should also be noted that this function is fair: If invoked twice without enough tokens for the first request to succeed, the first request will be serviced before subsequent requests.
This algorithm is a direct copy of Bucket4j BlockingBucket's tryConsume, except it suspends the calling coroutine's execution while waiting for available tokens, rather than blocking the thread. See the Bucket4j tryConsume documentation for more details.
true if the tokens were consumed, false otherwise.
The number of tokens to try and consume from the bucket. Must be a positive value.
The maximum amount of time to wait for the bucket to refill enough tokens such that the requested tokensToConsume can be consumed.