Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type QuotaExceededError ¶
QuotaExceededError provides the SDK error when the retries for a given token bucket have been exhausted.
func (QuotaExceededError) Error ¶
func (e QuotaExceededError) Error() string
type TokenBucket ¶
type TokenBucket struct {
// contains filtered or unexported fields
}
TokenBucket provides a concurrency safe utility for adding and removing tokens from the available token bucket.
func NewTokenBucket ¶
func NewTokenBucket(i uint) *TokenBucket
NewTokenBucket returns an initialized TokenBucket with the capacity specified.
func (*TokenBucket) Capacity ¶
func (t *TokenBucket) Capacity() uint
Capacity returns the maximum capacity of tokens that the bucket could contain.
func (*TokenBucket) Refund ¶
func (t *TokenBucket) Refund(amount uint)
Refund returns the amount of tokens back to the available token bucket, up to the initial capacity.
func (*TokenBucket) Remaining ¶
func (t *TokenBucket) Remaining() uint
Remaining returns the number of tokens that remaining in the bucket.
func (*TokenBucket) Resize ¶
func (t *TokenBucket) Resize(size uint) uint
Resize adjusts the size of the token bucket. Returns the capacity remaining.
func (*TokenBucket) Retrieve ¶
func (t *TokenBucket) Retrieve(amount uint) (available uint, retrieved bool)
Retrieve attempts to reduce the available tokens by the amount requested. If there are tokens available true will be returned along with the number of available tokens remaining. If amount requested is larger than the available capacity, false will be returned along with the available capacity. If the amount is less than the available capacity, the capacity will be reduced by that amount, and the remaining capacity and true will be returned.
type TokenRateLimit ¶
type TokenRateLimit struct {
// contains filtered or unexported fields
}
TokenRateLimit provides a Token Bucket RateLimiter implementation that limits the overall number of retry attempts that can be made across operation invocations.
func NewTokenRateLimit ¶
func NewTokenRateLimit(tokens uint) *TokenRateLimit
NewTokenRateLimit returns an TokenRateLimit with default values. Functional options can configure the retry rate limiter.
func (*TokenRateLimit) AddTokens ¶
func (l *TokenRateLimit) AddTokens(v uint) error
AddTokens increments the token bucket by a fixed amount.
func (*TokenRateLimit) GetToken ¶
GetToken may cause a available pool of retry quota to be decremented. Will return an error if the decremented value can not be reduced from the retry quota.
func (*TokenRateLimit) Remaining ¶
func (l *TokenRateLimit) Remaining() uint
Remaining returns the number of remaining tokens in the bucket.