Loading problem…
This problem builds on rate-limiter-sliding-window. Complete that first, then load your solution to continue.
Implement a per-key token bucket rate limiter.
Implement:
createTokenBucketLimiter should return:
Behavior:
capacity tokensrefillRatePerSec tokens per secondallow consumes cost tokens, where cost defaults to 1true if enough tokens exist, else falsetimestampMs instead of real time for deterministic behaviorcapacitycost values should be treated as 1