Struct ThrottlerImpl

Main throttler implementation

struct ThrottlerImpl(bool AllowOverdraft = false) ;

Implements Token Bucket QoS. Tokens are deposited into a bucket at a fixed rate. Consumers request withdrawl of tokens from the bucket. If the bucket does not have enough tokens, the request to withdraw is paused until such time as the bucket, again, has enough to allow the request to move forward.

The bucket size controls the burst rate, i.e. - the amount of tokens that can be withdrawn without wait after a long quiet period.

The throttler is strict first-come first-serve.

Properties

NameTypeDescription
isOpen[get] boolreports whether open the throttler is open.

Methods

NameDescription
close Closes the throtller.
open initialize a throttler for use.
withdraw Withdraw tokens from the bucket.

Parameters

NameDescription
AllowOverdraft there are two variants to the throttler. In the first (and default) variant, the tokens ballance must be able to fully cover the current request. The second variant allows a request to proceed even if there is not enough tokens at the moment (overdraw), so long as all previous debt has been repayed.