ThrottlerImpl

Main throttler implementation

Implements <a href="https://en.wikipedia.org/wiki/Token_bucket">Token Bucket</a> 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.

Destructor

~this
~this()
Undocumented in source.

Members

Functions

close
void close()

Closes the throtller.

open
void open(size_t tokensPerSecond, ulong burstSize)
void open(size_t tokensPerSecond, ulong burstSize, ulong numInitialTokens)

initialize a throttler for use.

withdraw
void withdraw(ulong tokens, Timeout timeout)

Withdraw tokens from the bucket.

Properties

isOpen
bool isOpen [@property getter]

reports whether open the throttler is open.

Parameters

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.

Meta