From dded552360fab3f12ed4df071fa94f504ef878b8 Mon Sep 17 00:00:00 2001 From: Luc Talatinian <102624213+lucix-aws@users.noreply.github.com> Date: Tue, 19 Mar 2024 10:56:16 -0400 Subject: [PATCH] add entry for ratelimit (#2565) --- .../docs/configuring-sdk/retries-timeouts.md | 70 +++++++++++++++++++ docs/404.html | 2 +- docs/docs/cloud9-go/index.html | 4 +- docs/docs/code-examples/cloudwatch/index.html | 4 +- docs/docs/code-examples/dynamodb/index.html | 4 +- docs/docs/code-examples/ec2/index.html | 4 +- docs/docs/code-examples/iam/index.html | 4 +- docs/docs/code-examples/index.html | 4 +- docs/docs/code-examples/kms/index.html | 4 +- docs/docs/code-examples/s3/index.html | 4 +- docs/docs/code-examples/sns/index.html | 4 +- docs/docs/code-examples/sqs/index.html | 4 +- docs/docs/code-examples/ssm/index.html | 4 +- docs/docs/code-examples/sts/index.html | 4 +- docs/docs/configuring-sdk/auth/index.html | 4 +- .../configuring-sdk/custom-http/index.html | 4 +- .../docs/configuring-sdk/endpoints/index.html | 4 +- docs/docs/configuring-sdk/index.html | 4 +- docs/docs/configuring-sdk/index.xml | 62 ++++++++++++++++ docs/docs/configuring-sdk/logging/index.html | 4 +- .../retries-timeouts/index.html | 69 +++++++++++++++++- docs/docs/faq/index.html | 4 +- docs/docs/faq/timing-operations/index.html | 4 +- docs/docs/getting-started/index.html | 4 +- docs/docs/handling-errors/index.html | 4 +- docs/docs/index.html | 4 +- docs/docs/index.xml | 62 ++++++++++++++++ docs/docs/making-requests/index.html | 4 +- docs/docs/middleware/index.html | 4 +- docs/docs/migrating/index.html | 8 +-- docs/docs/sdk-utilities/cloudfront/index.html | 4 +- docs/docs/sdk-utilities/ec2-imds/index.html | 4 +- docs/docs/sdk-utilities/index.html | 4 +- docs/docs/sdk-utilities/rds/index.html | 4 +- docs/docs/sdk-utilities/s3/index.html | 4 +- .../security/compliance-validation/index.html | 4 +- docs/docs/security/data-protection/index.html | 4 +- .../disaster-recovery-resiliency/index.html | 4 +- docs/docs/security/iam/index.html | 4 +- docs/docs/security/index.html | 4 +- .../infrastructure-security/index.html | 4 +- docs/docs/security/tls/index.html | 4 +- docs/docs/unit-testing/index.html | 4 +- docs/index.html | 2 +- docs/sitemap.xml | 2 +- 45 files changed, 341 insertions(+), 84 deletions(-) diff --git a/content/en/docs/configuring-sdk/retries-timeouts.md b/content/en/docs/configuring-sdk/retries-timeouts.md index cc154b22cf1..b25c8e36b0c 100644 --- a/content/en/docs/configuring-sdk/retries-timeouts.md +++ b/content/en/docs/configuring-sdk/retries-timeouts.md @@ -130,6 +130,76 @@ if err != nil { client := s3.NewFromConfig(cfg) ``` +### Client-side rate limiting + +The {{% alias sdk-go %}} introduces a new client-side rate-limiting mechanism +in the standard retry policy to align with the behavior of modern SDKs. This is +behavior is controlled by the [RateLimiter]({{< apiref "aws/retry#RateLimiter" >}}) +field on a retryer's [options]({{< apiref "aws/retry#StandardOptions" >}}). + +A RateLimiter operates as a token bucket with a set capacity, where operation +attempt failures consume tokens. A retry that attempts to consume more tokens +than what's available results in operation failure with a +[QuotaExceededError]({{< apiref "aws/ratelimit#QuotaExceededError" >}}). + +The default implementation is parameterized as follows (how to modify each setting): +- a capacity of 500 (set the value of RateLimiter on StandardOptions using [NewTokenRateLimit]({{< apiref "aws/ratelimit#NewTokenRateLimit" >}})) +- a retry caused by a timeout costs 10 tokens (set RetryCost on StandardOptions) +- a retry caused by other errors costs 5 tokens (set RetryTimeoutCost on StandardOptions) +- an operation that succeeds on the 1st attempt adds 1 token (set NoRetryIncrement on StandardOptions) + - operations that succeed on the 2nd or later attempt do not add back any tokens + +If you find that the default behavior does not fit your application's needs, +you can disable it with [ratelimit.None]({{< apiref "aws/ratelimit#pkg-variables" >}}). + +#### Example: modified rate limiter + +```go +import ( + "context" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/aws/ratelimit" + "github.com/aws/aws-sdk-go-v2/aws/retry" + "github.com/aws/aws-sdk-go-v2/config" +) + +// ... + +cfg, err := config.LoadDefaultConfig(context.Background(), config.WithRetryer(func() aws.Retryer { + return retry.NewStandard(func(o *retry.StandardOptions) { + // Makes the rate limiter more permissive in general. These values are + // arbitrary for demonstration and may not suit your specific + // application's needs. + o.RateLimiter = ratelimit.NewTokenRateLimit(1000) + o.RetryCost = 1 + o.RetryTimeoutCost = 3 + o.NoRetryIncrement = 10 + }) +})) +``` + +#### Example: no rate limit using ratelimit.None + +```go +import ( + "context" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/aws/ratelimit" + "github.com/aws/aws-sdk-go-v2/aws/retry" + "github.com/aws/aws-sdk-go-v2/config" +) + +// ... + +cfg, err := config.LoadDefaultConfig(context.Background(), config.WithRetryer(func() aws.Retryer { + return retry.NewStandard(func(o *retry.StandardOptions) { + o.RateLimiter = ratelimit.None + }) +})) +``` + ## Timeouts You use the [context](https://golang.org/pkg/context/) package to set timeouts or deadlines when invoking a service diff --git a/docs/404.html b/docs/404.html index 2dbee55521e..57a24397a11 100644 --- a/docs/404.html +++ b/docs/404.html @@ -99,7 +99,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/cloud9-go/index.html b/docs/docs/cloud9-go/index.html index 199f0709cd3..f0ee38069c6 100644 --- a/docs/docs/cloud9-go/index.html +++ b/docs/docs/cloud9-go/index.html @@ -105,7 +105,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -127,7 +127,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/code-examples/cloudwatch/index.html b/docs/docs/code-examples/cloudwatch/index.html index 05524c5d91d..0e8708ac634 100644 --- a/docs/docs/code-examples/cloudwatch/index.html +++ b/docs/docs/code-examples/cloudwatch/index.html @@ -101,7 +101,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -123,7 +123,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/code-examples/dynamodb/index.html b/docs/docs/code-examples/dynamodb/index.html index 7a74984dc58..7afcc4c0e33 100644 --- a/docs/docs/code-examples/dynamodb/index.html +++ b/docs/docs/code-examples/dynamodb/index.html @@ -101,7 +101,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -123,7 +123,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/code-examples/ec2/index.html b/docs/docs/code-examples/ec2/index.html index 6c54c5e7cac..dc02482bb1b 100644 --- a/docs/docs/code-examples/ec2/index.html +++ b/docs/docs/code-examples/ec2/index.html @@ -101,7 +101,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -123,7 +123,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/code-examples/iam/index.html b/docs/docs/code-examples/iam/index.html index 80136bd6dbd..efc83bc471b 100644 --- a/docs/docs/code-examples/iam/index.html +++ b/docs/docs/code-examples/iam/index.html @@ -101,7 +101,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -123,7 +123,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/code-examples/index.html b/docs/docs/code-examples/index.html index 098d4f51bda..c94e9cd3969 100644 --- a/docs/docs/code-examples/index.html +++ b/docs/docs/code-examples/index.html @@ -101,7 +101,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -123,7 +123,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/code-examples/kms/index.html b/docs/docs/code-examples/kms/index.html index 31ba6b5e7d0..78a0e77ba2e 100644 --- a/docs/docs/code-examples/kms/index.html +++ b/docs/docs/code-examples/kms/index.html @@ -101,7 +101,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -123,7 +123,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/code-examples/s3/index.html b/docs/docs/code-examples/s3/index.html index 805519cdb09..8d5adbeb511 100644 --- a/docs/docs/code-examples/s3/index.html +++ b/docs/docs/code-examples/s3/index.html @@ -101,7 +101,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -123,7 +123,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/code-examples/sns/index.html b/docs/docs/code-examples/sns/index.html index f82ca438892..f611fbf3d42 100644 --- a/docs/docs/code-examples/sns/index.html +++ b/docs/docs/code-examples/sns/index.html @@ -101,7 +101,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -123,7 +123,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/code-examples/sqs/index.html b/docs/docs/code-examples/sqs/index.html index 3aa1f6f9a65..daa51c25b8f 100644 --- a/docs/docs/code-examples/sqs/index.html +++ b/docs/docs/code-examples/sqs/index.html @@ -101,7 +101,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -123,7 +123,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/code-examples/ssm/index.html b/docs/docs/code-examples/ssm/index.html index 1809a3a3996..3b2a85b18e2 100644 --- a/docs/docs/code-examples/ssm/index.html +++ b/docs/docs/code-examples/ssm/index.html @@ -101,7 +101,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -123,7 +123,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/code-examples/sts/index.html b/docs/docs/code-examples/sts/index.html index dd34fa9c43e..333657bff24 100644 --- a/docs/docs/code-examples/sts/index.html +++ b/docs/docs/code-examples/sts/index.html @@ -101,7 +101,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -123,7 +123,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/configuring-sdk/auth/index.html b/docs/docs/configuring-sdk/auth/index.html index a7f0e8420d5..d59a92c8470 100644 --- a/docs/docs/configuring-sdk/auth/index.html +++ b/docs/docs/configuring-sdk/auth/index.html @@ -104,7 +104,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -126,7 +126,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/configuring-sdk/custom-http/index.html b/docs/docs/configuring-sdk/custom-http/index.html index 5d7f7197cdf..7a79ef6d068 100644 --- a/docs/docs/configuring-sdk/custom-http/index.html +++ b/docs/docs/configuring-sdk/custom-http/index.html @@ -104,7 +104,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -126,7 +126,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/configuring-sdk/endpoints/index.html b/docs/docs/configuring-sdk/endpoints/index.html index 192ed204bb4..5920b913743 100644 --- a/docs/docs/configuring-sdk/endpoints/index.html +++ b/docs/docs/configuring-sdk/endpoints/index.html @@ -104,7 +104,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -126,7 +126,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/configuring-sdk/index.html b/docs/docs/configuring-sdk/index.html index dea3c1e8a59..3567da4b56f 100644 --- a/docs/docs/configuring-sdk/index.html +++ b/docs/docs/configuring-sdk/index.html @@ -101,7 +101,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -123,7 +123,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/configuring-sdk/index.xml b/docs/docs/configuring-sdk/index.xml index a8f13801f68..2d55bc9d142 100644 --- a/docs/docs/configuring-sdk/index.xml +++ b/docs/docs/configuring-sdk/index.xml @@ -954,6 +954,68 @@ implementation and include additional API error codes that should be considered </span></span><span style="display:flex;"><span><span style="color:#000;font-weight:bold">}</span> </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#000">client</span> <span style="color:#ce5c00;font-weight:bold">:=</span> <span style="color:#000">s3</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">NewFromConfig</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">cfg</span><span style="color:#000;font-weight:bold">)</span> +</span></span></code></pre></div><h3 id="client-side-rate-limiting">Client-side rate limiting</h3> +<p>The AWS SDK for Go V2 introduces a new client-side rate-limiting mechanism +in the standard retry policy to align with the behavior of modern SDKs. This is +behavior is controlled by the <a href="https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/aws/retry#RateLimiter">RateLimiter</a> +field on a retryer’s <a href="https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/aws/retry#StandardOptions">options</a>.</p> +<p>A RateLimiter operates as a token bucket with a set capacity, where operation +attempt failures consume tokens. A retry that attempts to consume more tokens +than what’s available results in operation failure with a +<a href="https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/aws/ratelimit#QuotaExceededError">QuotaExceededError</a>.</p> +<p>The default implementation is parameterized as follows (how to modify each setting):</p> +<ul> +<li>a capacity of 500 (set the value of RateLimiter on StandardOptions using <a href="https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/aws/ratelimit#NewTokenRateLimit">NewTokenRateLimit</a>)</li> +<li>a retry caused by a timeout costs 10 tokens (set RetryCost on StandardOptions)</li> +<li>a retry caused by other errors costs 5 tokens (set RetryTimeoutCost on StandardOptions)</li> +<li>an operation that succeeds on the 1st attempt adds 1 token (set NoRetryIncrement on StandardOptions) +<ul> +<li>operations that succeed on the 2nd or later attempt do not add back any tokens</li> +</ul> +</li> +</ul> +<p>If you find that the default behavior does not fit your application’s needs, +you can disable it with <a href="https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/aws/ratelimit#pkg-variables">ratelimit.None</a>.</p> +<h4 id="example-modified-rate-limiter">Example: modified rate limiter</h4> +<div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#204a87;font-weight:bold">import</span> <span style="color:#000;font-weight:bold">(</span> +</span></span><span style="display:flex;"><span> <span style="color:#4e9a06">"context"</span> +</span></span><span style="display:flex;"><span> +</span></span><span style="display:flex;"><span> <span style="color:#4e9a06">"github.com/aws/aws-sdk-go-v2/aws"</span> +</span></span><span style="display:flex;"><span> <span style="color:#4e9a06">"github.com/aws/aws-sdk-go-v2/aws/ratelimit"</span> +</span></span><span style="display:flex;"><span> <span style="color:#4e9a06">"github.com/aws/aws-sdk-go-v2/aws/retry"</span> +</span></span><span style="display:flex;"><span> <span style="color:#4e9a06">"github.com/aws/aws-sdk-go-v2/config"</span> +</span></span><span style="display:flex;"><span><span style="color:#000;font-weight:bold">)</span> +</span></span><span style="display:flex;"><span> +</span></span><span style="display:flex;"><span><span style="color:#8f5902;font-style:italic">// ... +</span></span></span><span style="display:flex;"><span><span style="color:#8f5902;font-style:italic"></span> +</span></span><span style="display:flex;"><span><span style="color:#000">cfg</span><span style="color:#000;font-weight:bold">,</span> <span style="color:#000">err</span> <span style="color:#ce5c00;font-weight:bold">:=</span> <span style="color:#000">config</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">LoadDefaultConfig</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">context</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">Background</span><span style="color:#000;font-weight:bold">(),</span> <span style="color:#000">config</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">WithRetryer</span><span style="color:#000;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">func</span><span style="color:#000;font-weight:bold">()</span> <span style="color:#000">aws</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">Retryer</span> <span style="color:#000;font-weight:bold">{</span> +</span></span><span style="display:flex;"><span> <span style="color:#204a87;font-weight:bold">return</span> <span style="color:#000">retry</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">NewStandard</span><span style="color:#000;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">func</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">o</span> <span style="color:#ce5c00;font-weight:bold">*</span><span style="color:#000">retry</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">StandardOptions</span><span style="color:#000;font-weight:bold">)</span> <span style="color:#000;font-weight:bold">{</span> +</span></span><span style="display:flex;"><span> <span style="color:#8f5902;font-style:italic">// Makes the rate limiter more permissive in general. These values are +</span></span></span><span style="display:flex;"><span><span style="color:#8f5902;font-style:italic"></span> <span style="color:#8f5902;font-style:italic">// arbitrary for demonstration and may not suit your specific +</span></span></span><span style="display:flex;"><span><span style="color:#8f5902;font-style:italic"></span> <span style="color:#8f5902;font-style:italic">// application's needs. +</span></span></span><span style="display:flex;"><span><span style="color:#8f5902;font-style:italic"></span> <span style="color:#000">o</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">RateLimiter</span> <span style="color:#000;font-weight:bold">=</span> <span style="color:#000">ratelimit</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">NewTokenRateLimit</span><span style="color:#000;font-weight:bold">(</span><span style="color:#0000cf;font-weight:bold">1000</span><span style="color:#000;font-weight:bold">)</span> +</span></span><span style="display:flex;"><span> <span style="color:#000">o</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">RetryCost</span> <span style="color:#000;font-weight:bold">=</span> <span style="color:#0000cf;font-weight:bold">1</span> +</span></span><span style="display:flex;"><span> <span style="color:#000">o</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">RetryTimeoutCost</span> <span style="color:#000;font-weight:bold">=</span> <span style="color:#0000cf;font-weight:bold">3</span> +</span></span><span style="display:flex;"><span> <span style="color:#000">o</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">NoRetryIncrement</span> <span style="color:#000;font-weight:bold">=</span> <span style="color:#0000cf;font-weight:bold">10</span> +</span></span><span style="display:flex;"><span> <span style="color:#000;font-weight:bold">})</span> +</span></span><span style="display:flex;"><span><span style="color:#000;font-weight:bold">}))</span> +</span></span></code></pre></div><h4 id="example-no-rate-limit-using-ratelimitnone">Example: no rate limit using ratelimit.None</h4> +<div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#204a87;font-weight:bold">import</span> <span style="color:#000;font-weight:bold">(</span> +</span></span><span style="display:flex;"><span> <span style="color:#4e9a06">"context"</span> +</span></span><span style="display:flex;"><span> +</span></span><span style="display:flex;"><span> <span style="color:#4e9a06">"github.com/aws/aws-sdk-go-v2/aws"</span> +</span></span><span style="display:flex;"><span> <span style="color:#4e9a06">"github.com/aws/aws-sdk-go-v2/aws/ratelimit"</span> +</span></span><span style="display:flex;"><span> <span style="color:#4e9a06">"github.com/aws/aws-sdk-go-v2/aws/retry"</span> +</span></span><span style="display:flex;"><span> <span style="color:#4e9a06">"github.com/aws/aws-sdk-go-v2/config"</span> +</span></span><span style="display:flex;"><span><span style="color:#000;font-weight:bold">)</span> +</span></span><span style="display:flex;"><span> +</span></span><span style="display:flex;"><span><span style="color:#8f5902;font-style:italic">// ... +</span></span></span><span style="display:flex;"><span><span style="color:#8f5902;font-style:italic"></span> +</span></span><span style="display:flex;"><span><span style="color:#000">cfg</span><span style="color:#000;font-weight:bold">,</span> <span style="color:#000">err</span> <span style="color:#ce5c00;font-weight:bold">:=</span> <span style="color:#000">config</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">LoadDefaultConfig</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">context</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">Background</span><span style="color:#000;font-weight:bold">(),</span> <span style="color:#000">config</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">WithRetryer</span><span style="color:#000;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">func</span><span style="color:#000;font-weight:bold">()</span> <span style="color:#000">aws</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">Retryer</span> <span style="color:#000;font-weight:bold">{</span> +</span></span><span style="display:flex;"><span> <span style="color:#204a87;font-weight:bold">return</span> <span style="color:#000">retry</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">NewStandard</span><span style="color:#000;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">func</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">o</span> <span style="color:#ce5c00;font-weight:bold">*</span><span style="color:#000">retry</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">StandardOptions</span><span style="color:#000;font-weight:bold">)</span> <span style="color:#000;font-weight:bold">{</span> +</span></span><span style="display:flex;"><span> <span style="color:#000">o</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">RateLimiter</span> <span style="color:#000;font-weight:bold">=</span> <span style="color:#000">ratelimit</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">None</span> +</span></span><span style="display:flex;"><span> <span style="color:#000;font-weight:bold">})</span> +</span></span><span style="display:flex;"><span><span style="color:#000;font-weight:bold">}))</span> </span></span></code></pre></div><h2 id="timeouts">Timeouts</h2> <p>You use the <a href="https://golang.org/pkg/context/">context</a> package to set timeouts or deadlines when invoking a service client operation. Use the <a href="https://golang.org/pkg/context/#WithDeadline">context.WithDeadline</a> to wrap your applications diff --git a/docs/docs/configuring-sdk/logging/index.html b/docs/docs/configuring-sdk/logging/index.html index 6dbb66112d5..130407e4bf7 100644 --- a/docs/docs/configuring-sdk/logging/index.html +++ b/docs/docs/configuring-sdk/logging/index.html @@ -104,7 +104,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -126,7 +126,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/configuring-sdk/retries-timeouts/index.html b/docs/docs/configuring-sdk/retries-timeouts/index.html index 09e52baa261..765020a3510 100644 --- a/docs/docs/configuring-sdk/retries-timeouts/index.html +++ b/docs/docs/configuring-sdk/retries-timeouts/index.html @@ -32,7 +32,7 @@ - + @@ -130,7 +130,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -441,6 +441,7 @@
The AWS SDK for Go V2 introduces a new client-side rate-limiting mechanism +in the standard retry policy to align with the behavior of modern SDKs. This is +behavior is controlled by the RateLimiter +field on a retryer’s options.
+A RateLimiter operates as a token bucket with a set capacity, where operation +attempt failures consume tokens. A retry that attempts to consume more tokens +than what’s available results in operation failure with a +QuotaExceededError.
+The default implementation is parameterized as follows (how to modify each setting):
+If you find that the default behavior does not fit your application’s needs, +you can disable it with ratelimit.None.
+import (
+ "context"
+
+ "github.com/aws/aws-sdk-go-v2/aws"
+ "github.com/aws/aws-sdk-go-v2/aws/ratelimit"
+ "github.com/aws/aws-sdk-go-v2/aws/retry"
+ "github.com/aws/aws-sdk-go-v2/config"
+)
+
+// ...
+
+cfg, err := config.LoadDefaultConfig(context.Background(), config.WithRetryer(func() aws.Retryer {
+ return retry.NewStandard(func(o *retry.StandardOptions) {
+ // Makes the rate limiter more permissive in general. These values are
+ // arbitrary for demonstration and may not suit your specific
+ // application's needs.
+ o.RateLimiter = ratelimit.NewTokenRateLimit(1000)
+ o.RetryCost = 1
+ o.RetryTimeoutCost = 3
+ o.NoRetryIncrement = 10
+ })
+}))
+
import (
+ "context"
+
+ "github.com/aws/aws-sdk-go-v2/aws"
+ "github.com/aws/aws-sdk-go-v2/aws/ratelimit"
+ "github.com/aws/aws-sdk-go-v2/aws/retry"
+ "github.com/aws/aws-sdk-go-v2/config"
+)
+
+// ...
+
+cfg, err := config.LoadDefaultConfig(context.Background(), config.WithRetryer(func() aws.Retryer {
+ return retry.NewStandard(func(o *retry.StandardOptions) {
+ o.RateLimiter = ratelimit.None
+ })
+}))
You use the context package to set timeouts or deadlines when invoking a service client operation. Use the context.WithDeadline to wrap your applications diff --git a/docs/docs/faq/index.html b/docs/docs/faq/index.html index d1bf747ef3f..74b6fbda739 100644 --- a/docs/docs/faq/index.html +++ b/docs/docs/faq/index.html @@ -100,7 +100,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -122,7 +122,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/faq/timing-operations/index.html b/docs/docs/faq/timing-operations/index.html index cc4b74093da..41e69e520ed 100644 --- a/docs/docs/faq/timing-operations/index.html +++ b/docs/docs/faq/timing-operations/index.html @@ -104,7 +104,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -126,7 +126,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/getting-started/index.html b/docs/docs/getting-started/index.html index d79a849595c..2d33598dc54 100644 --- a/docs/docs/getting-started/index.html +++ b/docs/docs/getting-started/index.html @@ -112,7 +112,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -134,7 +134,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/handling-errors/index.html b/docs/docs/handling-errors/index.html index 49c25f2b05b..23de3be7d5d 100644 --- a/docs/docs/handling-errors/index.html +++ b/docs/docs/handling-errors/index.html @@ -104,7 +104,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -126,7 +126,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/index.html b/docs/docs/index.html index 4c501368cc3..7dc44ba13f9 100644 --- a/docs/docs/index.html +++ b/docs/docs/index.html @@ -101,7 +101,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -123,7 +123,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/index.xml b/docs/docs/index.xml index 7cbe0ead0bb..dc731bc0d57 100644 --- a/docs/docs/index.xml +++ b/docs/docs/index.xml @@ -3353,6 +3353,68 @@ implementation and include additional API error codes that should be considered </span></span><span style="display:flex;"><span><span style="color:#000;font-weight:bold">}</span> </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#000">client</span> <span style="color:#ce5c00;font-weight:bold">:=</span> <span style="color:#000">s3</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">NewFromConfig</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">cfg</span><span style="color:#000;font-weight:bold">)</span> +</span></span></code></pre></div><h3 id="client-side-rate-limiting">Client-side rate limiting</h3> +<p>The AWS SDK for Go V2 introduces a new client-side rate-limiting mechanism +in the standard retry policy to align with the behavior of modern SDKs. This is +behavior is controlled by the <a href="https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/aws/retry#RateLimiter">RateLimiter</a> +field on a retryer’s <a href="https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/aws/retry#StandardOptions">options</a>.</p> +<p>A RateLimiter operates as a token bucket with a set capacity, where operation +attempt failures consume tokens. A retry that attempts to consume more tokens +than what’s available results in operation failure with a +<a href="https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/aws/ratelimit#QuotaExceededError">QuotaExceededError</a>.</p> +<p>The default implementation is parameterized as follows (how to modify each setting):</p> +<ul> +<li>a capacity of 500 (set the value of RateLimiter on StandardOptions using <a href="https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/aws/ratelimit#NewTokenRateLimit">NewTokenRateLimit</a>)</li> +<li>a retry caused by a timeout costs 10 tokens (set RetryCost on StandardOptions)</li> +<li>a retry caused by other errors costs 5 tokens (set RetryTimeoutCost on StandardOptions)</li> +<li>an operation that succeeds on the 1st attempt adds 1 token (set NoRetryIncrement on StandardOptions) +<ul> +<li>operations that succeed on the 2nd or later attempt do not add back any tokens</li> +</ul> +</li> +</ul> +<p>If you find that the default behavior does not fit your application’s needs, +you can disable it with <a href="https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/aws/ratelimit#pkg-variables">ratelimit.None</a>.</p> +<h4 id="example-modified-rate-limiter">Example: modified rate limiter</h4> +<div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#204a87;font-weight:bold">import</span> <span style="color:#000;font-weight:bold">(</span> +</span></span><span style="display:flex;"><span> <span style="color:#4e9a06">"context"</span> +</span></span><span style="display:flex;"><span> +</span></span><span style="display:flex;"><span> <span style="color:#4e9a06">"github.com/aws/aws-sdk-go-v2/aws"</span> +</span></span><span style="display:flex;"><span> <span style="color:#4e9a06">"github.com/aws/aws-sdk-go-v2/aws/ratelimit"</span> +</span></span><span style="display:flex;"><span> <span style="color:#4e9a06">"github.com/aws/aws-sdk-go-v2/aws/retry"</span> +</span></span><span style="display:flex;"><span> <span style="color:#4e9a06">"github.com/aws/aws-sdk-go-v2/config"</span> +</span></span><span style="display:flex;"><span><span style="color:#000;font-weight:bold">)</span> +</span></span><span style="display:flex;"><span> +</span></span><span style="display:flex;"><span><span style="color:#8f5902;font-style:italic">// ... +</span></span></span><span style="display:flex;"><span><span style="color:#8f5902;font-style:italic"></span> +</span></span><span style="display:flex;"><span><span style="color:#000">cfg</span><span style="color:#000;font-weight:bold">,</span> <span style="color:#000">err</span> <span style="color:#ce5c00;font-weight:bold">:=</span> <span style="color:#000">config</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">LoadDefaultConfig</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">context</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">Background</span><span style="color:#000;font-weight:bold">(),</span> <span style="color:#000">config</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">WithRetryer</span><span style="color:#000;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">func</span><span style="color:#000;font-weight:bold">()</span> <span style="color:#000">aws</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">Retryer</span> <span style="color:#000;font-weight:bold">{</span> +</span></span><span style="display:flex;"><span> <span style="color:#204a87;font-weight:bold">return</span> <span style="color:#000">retry</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">NewStandard</span><span style="color:#000;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">func</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">o</span> <span style="color:#ce5c00;font-weight:bold">*</span><span style="color:#000">retry</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">StandardOptions</span><span style="color:#000;font-weight:bold">)</span> <span style="color:#000;font-weight:bold">{</span> +</span></span><span style="display:flex;"><span> <span style="color:#8f5902;font-style:italic">// Makes the rate limiter more permissive in general. These values are +</span></span></span><span style="display:flex;"><span><span style="color:#8f5902;font-style:italic"></span> <span style="color:#8f5902;font-style:italic">// arbitrary for demonstration and may not suit your specific +</span></span></span><span style="display:flex;"><span><span style="color:#8f5902;font-style:italic"></span> <span style="color:#8f5902;font-style:italic">// application's needs. +</span></span></span><span style="display:flex;"><span><span style="color:#8f5902;font-style:italic"></span> <span style="color:#000">o</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">RateLimiter</span> <span style="color:#000;font-weight:bold">=</span> <span style="color:#000">ratelimit</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">NewTokenRateLimit</span><span style="color:#000;font-weight:bold">(</span><span style="color:#0000cf;font-weight:bold">1000</span><span style="color:#000;font-weight:bold">)</span> +</span></span><span style="display:flex;"><span> <span style="color:#000">o</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">RetryCost</span> <span style="color:#000;font-weight:bold">=</span> <span style="color:#0000cf;font-weight:bold">1</span> +</span></span><span style="display:flex;"><span> <span style="color:#000">o</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">RetryTimeoutCost</span> <span style="color:#000;font-weight:bold">=</span> <span style="color:#0000cf;font-weight:bold">3</span> +</span></span><span style="display:flex;"><span> <span style="color:#000">o</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">NoRetryIncrement</span> <span style="color:#000;font-weight:bold">=</span> <span style="color:#0000cf;font-weight:bold">10</span> +</span></span><span style="display:flex;"><span> <span style="color:#000;font-weight:bold">})</span> +</span></span><span style="display:flex;"><span><span style="color:#000;font-weight:bold">}))</span> +</span></span></code></pre></div><h4 id="example-no-rate-limit-using-ratelimitnone">Example: no rate limit using ratelimit.None</h4> +<div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#204a87;font-weight:bold">import</span> <span style="color:#000;font-weight:bold">(</span> +</span></span><span style="display:flex;"><span> <span style="color:#4e9a06">"context"</span> +</span></span><span style="display:flex;"><span> +</span></span><span style="display:flex;"><span> <span style="color:#4e9a06">"github.com/aws/aws-sdk-go-v2/aws"</span> +</span></span><span style="display:flex;"><span> <span style="color:#4e9a06">"github.com/aws/aws-sdk-go-v2/aws/ratelimit"</span> +</span></span><span style="display:flex;"><span> <span style="color:#4e9a06">"github.com/aws/aws-sdk-go-v2/aws/retry"</span> +</span></span><span style="display:flex;"><span> <span style="color:#4e9a06">"github.com/aws/aws-sdk-go-v2/config"</span> +</span></span><span style="display:flex;"><span><span style="color:#000;font-weight:bold">)</span> +</span></span><span style="display:flex;"><span> +</span></span><span style="display:flex;"><span><span style="color:#8f5902;font-style:italic">// ... +</span></span></span><span style="display:flex;"><span><span style="color:#8f5902;font-style:italic"></span> +</span></span><span style="display:flex;"><span><span style="color:#000">cfg</span><span style="color:#000;font-weight:bold">,</span> <span style="color:#000">err</span> <span style="color:#ce5c00;font-weight:bold">:=</span> <span style="color:#000">config</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">LoadDefaultConfig</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">context</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">Background</span><span style="color:#000;font-weight:bold">(),</span> <span style="color:#000">config</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">WithRetryer</span><span style="color:#000;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">func</span><span style="color:#000;font-weight:bold">()</span> <span style="color:#000">aws</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">Retryer</span> <span style="color:#000;font-weight:bold">{</span> +</span></span><span style="display:flex;"><span> <span style="color:#204a87;font-weight:bold">return</span> <span style="color:#000">retry</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">NewStandard</span><span style="color:#000;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">func</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">o</span> <span style="color:#ce5c00;font-weight:bold">*</span><span style="color:#000">retry</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">StandardOptions</span><span style="color:#000;font-weight:bold">)</span> <span style="color:#000;font-weight:bold">{</span> +</span></span><span style="display:flex;"><span> <span style="color:#000">o</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">RateLimiter</span> <span style="color:#000;font-weight:bold">=</span> <span style="color:#000">ratelimit</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">None</span> +</span></span><span style="display:flex;"><span> <span style="color:#000;font-weight:bold">})</span> +</span></span><span style="display:flex;"><span><span style="color:#000;font-weight:bold">}))</span> </span></span></code></pre></div><h2 id="timeouts">Timeouts</h2> <p>You use the <a href="https://golang.org/pkg/context/">context</a> package to set timeouts or deadlines when invoking a service client operation. Use the <a href="https://golang.org/pkg/context/#WithDeadline">context.WithDeadline</a> to wrap your applications diff --git a/docs/docs/making-requests/index.html b/docs/docs/making-requests/index.html index 99492c4bea4..2eb7fd13dcc 100644 --- a/docs/docs/making-requests/index.html +++ b/docs/docs/making-requests/index.html @@ -104,7 +104,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -126,7 +126,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/middleware/index.html b/docs/docs/middleware/index.html index 89657a8236d..eb916b612db 100644 --- a/docs/docs/middleware/index.html +++ b/docs/docs/middleware/index.html @@ -104,7 +104,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -126,7 +126,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > diff --git a/docs/docs/migrating/index.html b/docs/docs/migrating/index.html index bbcdf84ffea..88e2d352416 100644 --- a/docs/docs/migrating/index.html +++ b/docs/docs/migrating/index.html @@ -100,7 +100,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -122,7 +122,7 @@ aria-label="Search this site…" autocomplete="off" - data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.f7b818cc28b8e9e5e837a0faaac05d9e.json" + data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.d8f87655e0fa72213f78a940133fec6c.json" data-offline-search-base-href="/" data-offline-search-max-results="10" > @@ -1142,7 +1142,7 @@