More...
|
| RateLimiter (int maxCallsPerMinute) |
| Constructs the rate limiter with the provided maxCallsPerMinute.
|
| RateLimiter (int maxCallsPerPeriod, TimeSpan period) |
| Configures the rate limiter with the provided max calls per provided period.
|
void | 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
-
|
async Task | 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
-
- Returns
|
void | Reset () |
| Resets the sliding window of known calls.
|
|
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.
|
◆ RateLimiter() [1/2]
PeanutButter.Utils.RateLimiter.RateLimiter |
( |
int | maxCallsPerMinute | ) |
|
Constructs the rate limiter with the provided maxCallsPerMinute.
- Parameters
-
◆ RateLimiter() [2/2]
PeanutButter.Utils.RateLimiter.RateLimiter |
( |
int | maxCallsPerPeriod, |
|
|
TimeSpan | period ) |
Configures the rate limiter with the provided max calls per provided period.
- Parameters
-
◆ Reset()
void PeanutButter.Utils.RateLimiter.Reset |
( |
| ) |
|
◆ Run()
void PeanutButter.Utils.RateLimiter.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
-
Implements PeanutButter.Utils.IRateLimiter.
◆ RunAsync()
async Task PeanutButter.Utils.RateLimiter.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
-
- Returns
Implements PeanutButter.Utils.IRateLimiter.
◆ CallsRunWithinLastPeriod
int PeanutButter.Utils.RateLimiter.CallsRunWithinLastPeriod |
|
get |
◆ MaxCallsPerPeriod
int PeanutButter.Utils.RateLimiter.MaxCallsPerPeriod |
|
getset |
◆ Period
TimeSpan PeanutButter.Utils.RateLimiter.Period |
|
get |
The documentation for this class was generated from the following file:
- source/Utils/PeanutButter.Utils/RateLimiter.cs