diff --git a/.changelog/df6f67adcf634eb48c3c35f3cc763f09.json b/.changelog/df6f67adcf634eb48c3c35f3cc763f09.json new file mode 100644 index 00000000000..04c11d4dba4 --- /dev/null +++ b/.changelog/df6f67adcf634eb48c3c35f3cc763f09.json @@ -0,0 +1,8 @@ +{ + "id": "df6f67ad-cf63-4eb4-8c3c-35f3cc763f09", + "type": "feature", + "description": "Add no-op rate limiting implementation `ratelimit.None`, which allows disabling of client-side retry quota behavior.", + "modules": [ + "." + ] +} \ No newline at end of file diff --git a/aws/ratelimit/none.go b/aws/ratelimit/none.go new file mode 100644 index 00000000000..8c78364105b --- /dev/null +++ b/aws/ratelimit/none.go @@ -0,0 +1,20 @@ +package ratelimit + +import "context" + +// None implements a no-op rate limiter which effectively disables client-side +// rate limiting (also known as "retry quotas"). +// +// GetToken does nothing and always returns a nil error. The returned +// token-release function does nothing, and always returns a nil error. +// +// AddTokens does nothing and always returns a nil error. +var None = &none{} + +type none struct{} + +func (*none) GetToken(ctx context.Context, cost uint) (func() error, error) { + return func() error { return nil }, nil +} + +func (*none) AddTokens(v uint) error { return nil } diff --git a/aws/retry/standard.go b/aws/retry/standard.go index 25abffc8128..d5ea93222ed 100644 --- a/aws/retry/standard.go +++ b/aws/retry/standard.go @@ -123,6 +123,17 @@ type StandardOptions struct { // Provides the rate limiting strategy for rate limiting attempt retries // across all attempts the retryer is being used with. + // + // A RateLimiter operates as a token bucket with a set capacity, where + // attempt failures events consume tokens. A retry attempt that attempts to + // consume more tokens than what's available results in operation failure. + // The default implementation is parameterized as follows: + // - a capacity of 500 (DefaultRetryRateTokens) + // - a retry caused by a timeout costs 10 tokens (DefaultRetryCost) + // - a retry caused by other errors costs 5 tokens (DefaultRetryTimeoutCost) + // - an operation that succeeds on the 1st attempt adds 1 token (DefaultNoRetryIncrement) + // + // You can disable rate limiting by setting this field to ratelimit.None. RateLimiter RateLimiter // The cost to deduct from the RateLimiter's token bucket per retry.