RateLimiter Class
Packages > @fluidframework/common-utils > RateLimiter
A rate limiter to make sure that a client can only request help for one task within a time window.
Signature:
export declare class RateLimiter
Constructors
Constructor | Modifiers | Description |
---|---|---|
(constructor)(windowMSec) | Creates a rate limiter that keep track of the request it has made |
Methods
Method | Modifiers | Description |
---|---|---|
filter(clientId, messages) | Filter out the messages that had already been requested within the time window |
Constructors
RateLimiter.(constructor)
Creates a rate limiter that keep track of the request it has made
Signature:
constructor(windowMSec: number);
Parameters
Parameter | Type | Description |
---|---|---|
windowMSec | number | time in millisecond, use to filter out messages for a clientId if the last request falls within this time window |
Methods
filter
Filter out the messages that had already been requested within the time window
Signature:
filter(clientId: string, messages: string[]): string[];
Parameters
Parameter | Type | Description |
---|---|---|
clientId | string | the clientId who want to send the message |
messages | string[] | the message we want to send |
Returns:
string[]
the message we approved to send that hasn’t been sent recently