RateLimiter
RateLimiter
#include <icy/ratelimiter.h>class RateLimiterDefined in src/base/include/icy/ratelimiter.h:23
Token bucket rate limiter for throttling message send frequency.
List of all members
| Name | Kind | Owner |
|---|---|---|
rate | variable | Declared here |
seconds | variable | Declared here |
allowance | variable | Declared here |
RateLimiter | function | Declared here |
canSend | function | Declared here |
_lastCheck | variable | Declared here |
_started | variable | Declared here |
Public Attributes
| Return | Name | Description |
|---|---|---|
double | rate | How many messages. |
double | seconds | Over how many seconds. |
double | allowance | Remaining send allowance. |
rate
double rateDefined in src/base/include/icy/ratelimiter.h:26
How many messages.
seconds
double secondsDefined in src/base/include/icy/ratelimiter.h:27
Over how many seconds.
allowance
double allowanceDefined in src/base/include/icy/ratelimiter.h:28
Remaining send allowance.
Public Methods
| Return | Name | Description |
|---|---|---|
RateLimiter inline | Constructs a token bucket limiter. | |
bool | canSend inline | Returns true if a message may be sent without exceeding the rate limit. Replenishes the token bucket based on elapsed time since the last check, then consumes one token. Returns false if the bucket is empty. |
RateLimiter
inline
inline RateLimiter(double rate = 5.0, double seconds = 6.0)Defined in src/base/include/icy/ratelimiter.h:33
Constructs a token bucket limiter.
Parameters
rateMaximum number of messages permitted in the window.secondsDuration of the replenishment window in seconds.
canSend
inline
inline bool canSend()Defined in src/base/include/icy/ratelimiter.h:46
Returns true if a message may be sent without exceeding the rate limit. Replenishes the token bucket based on elapsed time since the last check, then consumes one token. Returns false if the bucket is empty.
Returns
true if sending is allowed, false if the rate limit is exceeded.
Private Attributes
| Return | Name | Description |
|---|---|---|
std::chrono::steady_clock::time_point | _lastCheck | |
bool | _started |
_lastCheck
std::chrono::steady_clock::time_point _lastCheckDefined in src/base/include/icy/ratelimiter.h:76
_started
bool _started