RiotNet  8.0.0
A C#/.NET client for the Riot Games API.
Classes | Public Member Functions | Public Attributes | List of all members
RiotNet.RateLimiter Class Reference

Handles proactive rate limiting. You should only ever create one instance of this class. More...

Inheritance diagram for RiotNet.RateLimiter:
RiotNet.IRateLimiter

Classes

class  RateLimitTracker
 Represents a request count for a rate limiting rule. More...
 
class  RequestCount
 Represents a request count for a rate limiting rule. More...
 

Public Member Functions

 RateLimiter ()
 Creates a new RateLimiter instance. More...
 
virtual void TrySetRules (IEnumerable< RateLimitRule > rules, string platformId=null, IEnumerable< RateLimitRule > currentCounts=null)
 Adds application-level rate limiting rules if they have not been added already. More...
 
virtual void TrySetRules (IEnumerable< RateLimitRule > rules, string methodName, string platformId, IEnumerable< RateLimitRule > currentCounts=null)
 Adds method-level rate limiting rules if they have not been added already. More...
 
virtual DateTime AddRequestOrGetDelay (string methodName, string platformId)
 Increments the request count, or if the rate limit is reached, gets the time (in UTC) until which the client should wait before sending a request. More...
 

Public Attributes

virtual bool HasRules => appTrackers.Count > 0
 Gets whether the rate limiter has any rules set. More...
 

Additional Inherited Members

- Properties inherited from RiotNet.IRateLimiter
bool HasRules [get]
 Gets whether the rate limiter has any application-level rules set. More...
 

Detailed Description

Handles proactive rate limiting. You should only ever create one instance of this class.

Constructor & Destructor Documentation

RiotNet.RateLimiter.RateLimiter ( )
inline

Creates a new RateLimiter instance.

Member Function Documentation

virtual DateTime RiotNet.RateLimiter.AddRequestOrGetDelay ( string  methodName,
string  platformId 
)
inlinevirtual

Increments the request count, or if the rate limit is reached, gets the time (in UTC) until which the client should wait before sending a request.

Parameters
methodNameThe name of the method that is executing.
platformIdThe platform ID of the default server to connect to. This should equal one of the Models.PlatformId values.
Returns
The wait time, or DateTime.MinValue if no delay is required.

Implements RiotNet.IRateLimiter.

virtual void RiotNet.RateLimiter.TrySetRules ( IEnumerable< RateLimitRule rules,
string  platformId = null,
IEnumerable< RateLimitRule currentCounts = null 
)
inlinevirtual

Adds application-level rate limiting rules if they have not been added already.

Parameters
rulesThe list of rules.
platformIdThe platform ID of the response that contained the rate limit definitions. The request count will automatically be incremented for this platform.
currentCountsThe current request counts for each rule. If unspecified, 1 request for each rule will be assumed.

Implements RiotNet.IRateLimiter.

virtual void RiotNet.RateLimiter.TrySetRules ( IEnumerable< RateLimitRule rules,
string  methodName,
string  platformId,
IEnumerable< RateLimitRule currentCounts = null 
)
inlinevirtual

Adds method-level rate limiting rules if they have not been added already.

Parameters
rulesThe list of rules.
methodNameThe name of the method that is executing.
platformIdThe platform ID of the response that contained the rate limit definitions. The request count will automatically be incremented for this platform.
currentCountsThe current request counts for each rule. If unspecified, 1 request for each rule will be assumed.

Implements RiotNet.IRateLimiter.

Member Data Documentation

virtual bool RiotNet.RateLimiter.HasRules => appTrackers.Count > 0

Gets whether the rate limiter has any rules set.

Returns
True if any rules have been added, otherwise false.

The documentation for this class was generated from the following file: