admin管理员组文章数量:1295743
I just upgraded to AWS SDK V3 and I have no idea how to configure retryDelayOptions
and customBackoff
with it. I couldn't find any example code in AWS's own API reference or online. This is what I was doing previously:
retryDelayOptions: { customBackoff: (retryCount) => 2 ** (retryCount * 100) },
maxRetries: 2
I was passing the above as options into the client constructor. The retries seems to have changed quite a bit with V3 and I cannot make sense of the API without any examples. Any help is much appreciated
Regards, Deepak
I just upgraded to AWS SDK V3 and I have no idea how to configure retryDelayOptions
and customBackoff
with it. I couldn't find any example code in AWS's own API reference or online. This is what I was doing previously:
retryDelayOptions: { customBackoff: (retryCount) => 2 ** (retryCount * 100) },
maxRetries: 2
I was passing the above as options into the client constructor. The retries seems to have changed quite a bit with V3 and I cannot make sense of the API without any examples. Any help is much appreciated
Regards, Deepak
Share Improve this question edited Feb 13 at 10:31 Yves M. 31k24 gold badges109 silver badges149 bronze badges asked Mar 10, 2022 at 18:21 Deepak Thankachan MathewsDeepak Thankachan Mathews 1011 silver badge6 bronze badges 1-
Note that
^
is a bitwise operator - I believe you intended to use**
– Gershom Maes Commented Aug 29, 2023 at 19:24
3 Answers
Reset to default 3I think I figured it out
const { StandardRetryStrategy } = require("@aws-sdk/middleware-retry");
module.exports = (maxAttempts) =>
new StandardRetryStrategy(async () => maxAttempts, {
// eslint-disable-next-line no-bitwise
delayDecider: (delayBase, attempts) => 2 ** (attempts * 100)
})
and then you can pass this as retryStrategy
As @philipp mented, the @aws-sdk/middleware-retry
lib is deprecated, the way to set it up right now it is using @aws-sdk/util-retry
lib.
To configure it can be found here
import { S3Client } from "@aws-sdk/client-s3";
import { ConfiguredRetryStrategy } from "@aws-sdk/util-retry";
const client = new S3Client({
retryStrategy: new ConfiguredRetryStrategy(
4, // max attempts.
(attempt: number) => 100 + attempt * 1000 // backoff function.
),
});
Updating the above 2 answers:
@aws-sdk/util-retry
is also deprecated. Use @smithy/util-retry
instead.
import { S3Client } from "@aws-sdk/client-s3";
import { ConfiguredRetryStrategy } from "@smithy/util-retry";
const client = new S3Client({
retryStrategy: new ConfiguredRetryStrategy(
4, // max attempts.
(attempt: number) => 100 + attempt * 1000 // backoff function.
),
});
Here is the docs
本文标签: amazon web servicesSet customBackoff for AWS SDK JavaScript V3 retriesStack Overflow
版权声明:本文标题:amazon web services - Set customBackoff for AWS SDK JavaScript V3 retries - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741623687a2388959.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论