Lean  $LEAN_TAG$
QuantConnect.Util.RateLimit.ITokenBucket Interface Reference

Defines a token bucket for rate limiting See: https://en.wikipedia.org/wiki/Token_bucket More...

Inheritance diagram for QuantConnect.Util.RateLimit.ITokenBucket:
[legend]

Public Member Functions

void Consume (long tokens, long timeout=Timeout.Infinite)
 Blocks until the specified number of tokens are available for consumption and then consumes that number of tokens. More...
 
bool TryConsume (long tokens)
 Attempts to consume the specified number of tokens from the bucket. If the requested number of tokens are not immediately available, then this method will return false to indicate that zero tokens have been consumed. More...
 

Properties

long Capacity [get]
 Gets the maximum capacity of tokens this bucket can hold. More...
 
long AvailableTokens [get]
 Gets the total number of currently available tokens for consumption More...
 

Detailed Description

Defines a token bucket for rate limiting See: https://en.wikipedia.org/wiki/Token_bucket

This code is ported from https://github.com/mxplusb/TokenBucket - since it's a dotnet core project, there were issued importing the nuget package directly. The referenced repository is provided under the Apache V2 license.

Definition at line 30 of file ITokenBucket.cs.

Member Function Documentation

◆ Consume()

void QuantConnect.Util.RateLimit.ITokenBucket.Consume ( long  tokens,
long  timeout = Timeout.Infinite 
)

Blocks until the specified number of tokens are available for consumption and then consumes that number of tokens.

Parameters
tokensThe number of tokens to consume
timeoutThe maximum amount of time, in milliseconds, to block. A TimeoutException is throw in the event it takes longer than the stated timeout to consume the requested number of tokens. The default timeout is set to infinite, which will block forever.

Implemented in QuantConnect.Util.RateLimit.LeakyBucket.

Here is the caller graph for this function:

◆ TryConsume()

bool QuantConnect.Util.RateLimit.ITokenBucket.TryConsume ( long  tokens)

Attempts to consume the specified number of tokens from the bucket. If the requested number of tokens are not immediately available, then this method will return false to indicate that zero tokens have been consumed.

Implemented in QuantConnect.Util.RateLimit.LeakyBucket.

Here is the caller graph for this function:

Property Documentation

◆ Capacity

long QuantConnect.Util.RateLimit.ITokenBucket.Capacity
get

Gets the maximum capacity of tokens this bucket can hold.

Definition at line 35 of file ITokenBucket.cs.

◆ AvailableTokens

long QuantConnect.Util.RateLimit.ITokenBucket.AvailableTokens
get

Gets the total number of currently available tokens for consumption

Definition at line 40 of file ITokenBucket.cs.


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