LeakyBucketAlgorithm
LeakyBucketAlgorithm
Leaky bucket algorithm for smoothing output to a steady rate.
Signature
class LeakyBucketAlgorithm implements RateLimitAlgorithm {
public readonly type: RateLimitAlgorithmType = 'leaky-bucket';
constructor(storage: RateLimitStorage, config: LeakyBucketConfig)
consume(key: string) => Promise<RateLimitResult>;
reset(key: string) => Promise<void>;
}
- Implements:
RateLimitAlgorithm
type
property
constructor
method
(storage: RateLimitStorage, config: LeakyBucketConfig) => LeakyBucketAlgorithmCreate a leaky-bucket algorithm bound to a storage backend.
consume
method
(key: string) => Promise<RateLimitResult>Record one attempt and return the current bucket status for this key.
reset
method
(key: string) => Promise<void>Reset the stored key state for this limiter.