Skip to main content

Module throttle

Module throttle 

Source
Expand description

Pure token-bucket consume arithmetic.

Structs§

AvailableTokens
Tokens currently sitting in the bucket, available to grant.
BurstCapacity
The burst cap: the maximum the bucket may hold after a refill.
GrantedTokens
Tokens actually granted by a consume call (<= requested).
NewAvailable
The bucket’s new available count after a consume call commits.
RefillTokens
Tokens accrued since the last refill, to be added to available this call.
RequestedTokens
Tokens the caller is asking to consume.

Functions§

plan_consume
Caps a refill, grants at most the request, and returns the new balance.