1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.AdaptiveRetryStrategy = void 0;
|
4 | const util_retry_1 = require("@aws-sdk/util-retry");
|
5 | const StandardRetryStrategy_1 = require("./StandardRetryStrategy");
|
6 | class AdaptiveRetryStrategy extends StandardRetryStrategy_1.StandardRetryStrategy {
|
7 | constructor(maxAttemptsProvider, options) {
|
8 | const { rateLimiter, ...superOptions } = options !== null && options !== void 0 ? options : {};
|
9 | super(maxAttemptsProvider, superOptions);
|
10 | this.rateLimiter = rateLimiter !== null && rateLimiter !== void 0 ? rateLimiter : new util_retry_1.DefaultRateLimiter();
|
11 | this.mode = util_retry_1.RETRY_MODES.ADAPTIVE;
|
12 | }
|
13 | async retry(next, args) {
|
14 | return super.retry(next, args, {
|
15 | beforeRequest: async () => {
|
16 | return this.rateLimiter.getSendToken();
|
17 | },
|
18 | afterRequest: (response) => {
|
19 | this.rateLimiter.updateClientSendingRate(response);
|
20 | },
|
21 | });
|
22 | }
|
23 | }
|
24 | exports.AdaptiveRetryStrategy = AdaptiveRetryStrategy;
|