aws-sdk-go-v2: Index | Files

package ratelimit

import ""


Package Files

token_bucket.go token_rate_limit.go

type QuotaExceededError Uses

type QuotaExceededError struct {
    Available uint
    Requested uint

QuotaExceededError provides the SDK error when the retries for a given token bucket have been exhausted.

func (QuotaExceededError) Error Uses

func (e QuotaExceededError) Error() string

type TokenBucket Uses

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 Uses

func NewTokenBucket(i uint) *TokenBucket

NewTokenBucket returns an initialized TokenBucket with the capacity specified.

func (*TokenBucket) Refund Uses

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) Retrieve Uses

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

type TokenRateLimit Uses

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 Uses

func NewTokenRateLimit(tokens uint) *TokenRateLimit

NewTokenRateLimit returns an TokenRateLimit with default values. Functional options can configure the retry rate limiter.

func (*TokenRateLimit) AddTokens Uses

func (l *TokenRateLimit) AddTokens(v uint) error

AddTokens increments the token bucket by a fixed amount.

func (*TokenRateLimit) GetToken Uses

func (l *TokenRateLimit) GetToken(ctx context.Context, cost uint) (func() error, error)

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.

Package ratelimit imports 3 packages (graph) and is imported by 1 packages. Updated 2020-03-11. Refresh now. Tools for package owners.