PeanutButter
Loading...
Searching...
No Matches
PeanutButter.Utils.IRateLimiter Interface Reference

Provides a mechanism for rate-limiting calls to blocks of code. Calls made within limits are executed, those which exceed limits are dropped. More...

Inheritance diagram for PeanutButter.Utils.IRateLimiter:
PeanutButter.Utils.RateLimiter

Public Member Functions

void Run (Action action)
 Runs the synchronous code, rate-limited.
Task RunAsync (Func< Task > action)
 Runs the asynchronous code, rate-limited.
void Reset ()
 Resets the sliding window of known calls.

Properties

int MaxCallsPerPeriod [get, set]
 The configured max-calls-per-minute, which can be modified at runtime.
TimeSpan Period [get]
 The configured period to rate limit over (read-only, for information only)
int CallsRunWithinLastPeriod [get]
 Reports the number of calls which have been successfully run during the last sliding window period.

Detailed Description

Provides a mechanism for rate-limiting calls to blocks of code. Calls made within limits are executed, those which exceed limits are dropped.

Member Function Documentation

◆ Reset()

void PeanutButter.Utils.IRateLimiter.Reset ( )

Resets the sliding window of known calls.

Implemented in PeanutButter.Utils.RateLimiter.

◆ Run()

void PeanutButter.Utils.IRateLimiter.Run ( Action action)

Runs the synchronous code, rate-limited.

  • calls which come in within the sliding minute are performed until the configured rate per minute is reached, and extra calls are discarded
Parameters
action

Implemented in PeanutButter.Utils.RateLimiter.

◆ RunAsync()

Task PeanutButter.Utils.IRateLimiter.RunAsync ( Func< Task > action)

Runs the asynchronous code, rate-limited.

  • calls which come in within the sliding minute are performed until the configured rate per minute is reached, and extra calls are discarded
Parameters
action
Returns

Implemented in PeanutButter.Utils.RateLimiter.

Property Documentation

◆ CallsRunWithinLastPeriod

int PeanutButter.Utils.IRateLimiter.CallsRunWithinLastPeriod
get

Reports the number of calls which have been successfully run during the last sliding window period.

Implemented in PeanutButter.Utils.RateLimiter.

◆ MaxCallsPerPeriod

int PeanutButter.Utils.IRateLimiter.MaxCallsPerPeriod
getset

The configured max-calls-per-minute, which can be modified at runtime.

Implemented in PeanutButter.Utils.RateLimiter.

◆ Period

TimeSpan PeanutButter.Utils.IRateLimiter.Period
get

The configured period to rate limit over (read-only, for information only)

Implemented in PeanutButter.Utils.RateLimiter.


The documentation for this interface was generated from the following file:
  • source/Utils/PeanutButter.Utils/RateLimiter.cs