Skip to content 

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

List of constructors for this class
Constructor Modifiers Description
(constructor)(windowMSec) Creates a rate limiter that keep track of the request it has made

Methods

List of methods on this class
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

List of 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

List of 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