Attempts to consume some number of tokens. Tokens are first added to the bucket based on the time elapsed since the last attempt to consume tokens. Note: Attempts to consume more tokens than the burst size will always fail.
Synopsis
Declared in <folly/TokenBucket.h>
bool
consume(
double toConsume,
double rate,
double burstSize,
double nowInSeconds = defaultClockNow());
Description
Thread‐safe.
Return Value
True if the rate limit check passed, false otherwise.
Parameters
Name |
Description |
toConsume |
The number of tokens to consume. |
rate |
Number of tokens to generate per second. |
burstSize |
Maximum burst size. Must be greater than 0. |
nowInSeconds |
Current time in seconds. Should be monotonically increasing from the nowInSeconds specified in this token bucket's constructor. |
Created with MrDocs