C# Класс Bert.RateLimiters.RollingWindowThrottler

Used to control the rate of occurrences of an action per unit of time.
The algorithm uses a rolling time window so that precise control over the rate is achieved (without any bursts)
Показать файл Открыть проект

Открытые методы

Метод Описание
RollingWindowThrottler ( int occurrences, System.TimeSpan timeUnit ) : System

Constructs an instance of the throttler.

ShouldThrottle ( int tokens, long &waitTimeMillis ) : bool

Tries to reserve tokens in the configured time unit.

ShouldThrottle ( long &waitTimeMillis ) : bool

Tries to reserve one token in the configured time unit.

Приватные методы

Метод Описание
CheckExitTimeQueue ( ) : void

Описание методов

RollingWindowThrottler() публичный Метод

Constructs an instance of the throttler.
public RollingWindowThrottler ( int occurrences, System.TimeSpan timeUnit ) : System
occurrences int Maximum number of occurences per time unit allowed.
timeUnit System.TimeSpan The time unit in which the occurences are constrained.
Результат System

ShouldThrottle() публичный Метод

Tries to reserve tokens in the configured time unit.
public ShouldThrottle ( int tokens, long &waitTimeMillis ) : bool
tokens int total number of reservations
waitTimeMillis long total suggested wait time in milliseconds till tokens will become available for reservation
Результат bool

ShouldThrottle() публичный Метод

Tries to reserve one token in the configured time unit.
public ShouldThrottle ( long &waitTimeMillis ) : bool
waitTimeMillis long total suggested wait time in milliseconds till tokens will become available for reservation
Результат bool