@smithy/middleware-retry 4.5.6 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/index.js +22 -396
- package/dist-es/index.js +1 -8
- package/dist-types/index.d.ts +3 -8
- package/package.json +5 -44
- package/README.md +0 -24
- package/dist-cjs/isStreamingPayload/isStreamingPayload.browser.js +0 -5
- package/dist-cjs/isStreamingPayload/isStreamingPayload.js +0 -7
- package/dist-es/configurations.js +0 -48
- package/dist-es/isStreamingPayload/isStreamingPayload.browser.js +0 -1
- package/dist-es/isStreamingPayload/isStreamingPayload.js +0 -3
- package/dist-es/longPollMiddleware.js +0 -15
- package/dist-es/omitRetryHeadersMiddleware.js +0 -22
- package/dist-es/parseRetryAfterHeader.js +0 -49
- package/dist-es/retry-pre-sra-deprecated/AdaptiveRetryStrategy.js +0 -21
- package/dist-es/retry-pre-sra-deprecated/StandardRetryStrategy.js +0 -94
- package/dist-es/retry-pre-sra-deprecated/defaultRetryQuota.js +0 -27
- package/dist-es/retry-pre-sra-deprecated/delayDecider.js +0 -2
- package/dist-es/retry-pre-sra-deprecated/retryDecider.js +0 -7
- package/dist-es/retry-pre-sra-deprecated/types.js +0 -1
- package/dist-es/retryMiddleware.js +0 -105
- package/dist-es/util.js +0 -9
- package/dist-types/configurations.d.ts +0 -68
- package/dist-types/isStreamingPayload/isStreamingPayload.browser.d.ts +0 -5
- package/dist-types/isStreamingPayload/isStreamingPayload.d.ts +0 -5
- package/dist-types/longPollMiddleware.d.ts +0 -15
- package/dist-types/omitRetryHeadersMiddleware.d.ts +0 -15
- package/dist-types/parseRetryAfterHeader.d.ts +0 -10
- package/dist-types/retry-pre-sra-deprecated/AdaptiveRetryStrategy.d.ts +0 -24
- package/dist-types/retry-pre-sra-deprecated/StandardRetryStrategy.d.ts +0 -33
- package/dist-types/retry-pre-sra-deprecated/defaultRetryQuota.d.ts +0 -26
- package/dist-types/retry-pre-sra-deprecated/delayDecider.d.ts +0 -6
- package/dist-types/retry-pre-sra-deprecated/retryDecider.d.ts +0 -6
- package/dist-types/retry-pre-sra-deprecated/types.d.ts +0 -65
- package/dist-types/retryMiddleware.d.ts +0 -14
- package/dist-types/util.d.ts +0 -2
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { parseRfc7231DateTime } from "@smithy/core/serde";
|
|
2
|
-
import { HttpResponse } from "@smithy/protocol-http";
|
|
3
|
-
export function parseRetryAfterHeader(response, logger) {
|
|
4
|
-
if (!HttpResponse.isInstance(response)) {
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
|
-
for (const header of Object.keys(response.headers)) {
|
|
8
|
-
const h = header.toLowerCase();
|
|
9
|
-
if (h === "retry-after") {
|
|
10
|
-
const retryAfter = response.headers[header];
|
|
11
|
-
let retryAfterSeconds = NaN;
|
|
12
|
-
if (retryAfter.endsWith("GMT")) {
|
|
13
|
-
try {
|
|
14
|
-
const date = parseRfc7231DateTime(retryAfter);
|
|
15
|
-
retryAfterSeconds = (date.getTime() - Date.now()) / 1000;
|
|
16
|
-
}
|
|
17
|
-
catch (e) {
|
|
18
|
-
logger?.trace?.("Failed to parse retry-after header");
|
|
19
|
-
logger?.trace?.(e);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
else if (retryAfter.match(/ GMT, ((\d+)|(\d+\.\d+))$/)) {
|
|
23
|
-
retryAfterSeconds = Number(retryAfter.match(/ GMT, ([\d.]+)$/)?.[1]);
|
|
24
|
-
}
|
|
25
|
-
else if (retryAfter.match(/^((\d+)|(\d+\.\d+))$/)) {
|
|
26
|
-
retryAfterSeconds = Number(retryAfter);
|
|
27
|
-
}
|
|
28
|
-
else if (Date.parse(retryAfter) >= Date.now()) {
|
|
29
|
-
retryAfterSeconds = (Date.parse(retryAfter) - Date.now()) / 1000;
|
|
30
|
-
}
|
|
31
|
-
if (isNaN(retryAfterSeconds)) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
return new Date(Date.now() + retryAfterSeconds * 1000);
|
|
35
|
-
}
|
|
36
|
-
else if (h === "x-amz-retry-after") {
|
|
37
|
-
const v = response.headers[header];
|
|
38
|
-
const backoffMilliseconds = Number(v);
|
|
39
|
-
if (isNaN(backoffMilliseconds)) {
|
|
40
|
-
logger?.trace?.(`Failed to parse x-amz-retry-after=${v}`);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
return new Date(Date.now() + backoffMilliseconds);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
export function getRetryAfterHint(response, logger) {
|
|
48
|
-
return parseRetryAfterHeader(response, logger);
|
|
49
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { DefaultRateLimiter, RETRY_MODES } from "@smithy/util-retry";
|
|
2
|
-
import { StandardRetryStrategy } from "./StandardRetryStrategy";
|
|
3
|
-
export class AdaptiveRetryStrategy extends StandardRetryStrategy {
|
|
4
|
-
rateLimiter;
|
|
5
|
-
constructor(maxAttemptsProvider, options) {
|
|
6
|
-
const { rateLimiter, ...superOptions } = options ?? {};
|
|
7
|
-
super(maxAttemptsProvider, superOptions);
|
|
8
|
-
this.rateLimiter = rateLimiter ?? new DefaultRateLimiter();
|
|
9
|
-
this.mode = RETRY_MODES.ADAPTIVE;
|
|
10
|
-
}
|
|
11
|
-
async retry(next, args) {
|
|
12
|
-
return super.retry(next, args, {
|
|
13
|
-
beforeRequest: async () => {
|
|
14
|
-
return this.rateLimiter.getSendToken();
|
|
15
|
-
},
|
|
16
|
-
afterRequest: (response) => {
|
|
17
|
-
this.rateLimiter.updateClientSendingRate(response);
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { HttpRequest, HttpResponse } from "@smithy/protocol-http";
|
|
2
|
-
import { isThrottlingError } from "@smithy/service-error-classification";
|
|
3
|
-
import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_DELAY_BASE, INITIAL_RETRY_TOKENS, INVOCATION_ID_HEADER, REQUEST_HEADER, RETRY_MODES, THROTTLING_RETRY_DELAY_BASE, } from "@smithy/util-retry";
|
|
4
|
-
import { v4 } from "@smithy/uuid";
|
|
5
|
-
import { asSdkError } from "../util";
|
|
6
|
-
import { getDefaultRetryQuota } from "./defaultRetryQuota";
|
|
7
|
-
import { defaultDelayDecider } from "./delayDecider";
|
|
8
|
-
import { defaultRetryDecider } from "./retryDecider";
|
|
9
|
-
export class StandardRetryStrategy {
|
|
10
|
-
maxAttemptsProvider;
|
|
11
|
-
retryDecider;
|
|
12
|
-
delayDecider;
|
|
13
|
-
retryQuota;
|
|
14
|
-
mode = RETRY_MODES.STANDARD;
|
|
15
|
-
constructor(maxAttemptsProvider, options) {
|
|
16
|
-
this.maxAttemptsProvider = maxAttemptsProvider;
|
|
17
|
-
this.retryDecider = options?.retryDecider ?? defaultRetryDecider;
|
|
18
|
-
this.delayDecider = options?.delayDecider ?? defaultDelayDecider;
|
|
19
|
-
this.retryQuota = options?.retryQuota ?? getDefaultRetryQuota(INITIAL_RETRY_TOKENS);
|
|
20
|
-
}
|
|
21
|
-
shouldRetry(error, attempts, maxAttempts) {
|
|
22
|
-
return attempts < maxAttempts && this.retryDecider(error) && this.retryQuota.hasRetryTokens(error);
|
|
23
|
-
}
|
|
24
|
-
async getMaxAttempts() {
|
|
25
|
-
let maxAttempts;
|
|
26
|
-
try {
|
|
27
|
-
maxAttempts = await this.maxAttemptsProvider();
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
maxAttempts = DEFAULT_MAX_ATTEMPTS;
|
|
31
|
-
}
|
|
32
|
-
return maxAttempts;
|
|
33
|
-
}
|
|
34
|
-
async retry(next, args, options) {
|
|
35
|
-
let retryTokenAmount;
|
|
36
|
-
let attempts = 0;
|
|
37
|
-
let totalDelay = 0;
|
|
38
|
-
const maxAttempts = await this.getMaxAttempts();
|
|
39
|
-
const { request } = args;
|
|
40
|
-
if (HttpRequest.isInstance(request)) {
|
|
41
|
-
request.headers[INVOCATION_ID_HEADER] = v4();
|
|
42
|
-
}
|
|
43
|
-
while (true) {
|
|
44
|
-
try {
|
|
45
|
-
if (HttpRequest.isInstance(request)) {
|
|
46
|
-
request.headers[REQUEST_HEADER] = `attempt=${attempts + 1}; max=${maxAttempts}`;
|
|
47
|
-
}
|
|
48
|
-
if (options?.beforeRequest) {
|
|
49
|
-
await options.beforeRequest();
|
|
50
|
-
}
|
|
51
|
-
const { response, output } = await next(args);
|
|
52
|
-
if (options?.afterRequest) {
|
|
53
|
-
options.afterRequest(response);
|
|
54
|
-
}
|
|
55
|
-
this.retryQuota.releaseRetryTokens(retryTokenAmount);
|
|
56
|
-
output.$metadata.attempts = attempts + 1;
|
|
57
|
-
output.$metadata.totalRetryDelay = totalDelay;
|
|
58
|
-
return { response, output };
|
|
59
|
-
}
|
|
60
|
-
catch (e) {
|
|
61
|
-
const err = asSdkError(e);
|
|
62
|
-
attempts++;
|
|
63
|
-
if (this.shouldRetry(err, attempts, maxAttempts)) {
|
|
64
|
-
retryTokenAmount = this.retryQuota.retrieveRetryTokens(err);
|
|
65
|
-
const delayFromDecider = this.delayDecider(isThrottlingError(err) ? THROTTLING_RETRY_DELAY_BASE : DEFAULT_RETRY_DELAY_BASE, attempts);
|
|
66
|
-
const delayFromResponse = getDelayFromRetryAfterHeader(err.$response);
|
|
67
|
-
const delay = Math.max(delayFromResponse || 0, delayFromDecider);
|
|
68
|
-
totalDelay += delay;
|
|
69
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
if (!err.$metadata) {
|
|
73
|
-
err.$metadata = {};
|
|
74
|
-
}
|
|
75
|
-
err.$metadata.attempts = attempts;
|
|
76
|
-
err.$metadata.totalRetryDelay = totalDelay;
|
|
77
|
-
throw err;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
const getDelayFromRetryAfterHeader = (response) => {
|
|
83
|
-
if (!HttpResponse.isInstance(response))
|
|
84
|
-
return;
|
|
85
|
-
const retryAfterHeaderName = Object.keys(response.headers).find((key) => key.toLowerCase() === "retry-after");
|
|
86
|
-
if (!retryAfterHeaderName)
|
|
87
|
-
return;
|
|
88
|
-
const retryAfter = response.headers[retryAfterHeaderName];
|
|
89
|
-
const retryAfterSeconds = Number(retryAfter);
|
|
90
|
-
if (!Number.isNaN(retryAfterSeconds))
|
|
91
|
-
return retryAfterSeconds * 1000;
|
|
92
|
-
const retryAfterDate = new Date(retryAfter);
|
|
93
|
-
return retryAfterDate.getTime() - Date.now();
|
|
94
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { NO_RETRY_INCREMENT, RETRY_COST, TIMEOUT_RETRY_COST } from "@smithy/util-retry";
|
|
2
|
-
export const getDefaultRetryQuota = (initialRetryTokens, options) => {
|
|
3
|
-
const MAX_CAPACITY = initialRetryTokens;
|
|
4
|
-
const noRetryIncrement = options?.noRetryIncrement ?? NO_RETRY_INCREMENT;
|
|
5
|
-
const retryCost = options?.retryCost ?? RETRY_COST;
|
|
6
|
-
const timeoutRetryCost = options?.timeoutRetryCost ?? TIMEOUT_RETRY_COST;
|
|
7
|
-
let availableCapacity = initialRetryTokens;
|
|
8
|
-
const getCapacityAmount = (error) => (error.name === "TimeoutError" ? timeoutRetryCost : retryCost);
|
|
9
|
-
const hasRetryTokens = (error) => getCapacityAmount(error) <= availableCapacity;
|
|
10
|
-
const retrieveRetryTokens = (error) => {
|
|
11
|
-
if (!hasRetryTokens(error)) {
|
|
12
|
-
throw new Error("No retry token available");
|
|
13
|
-
}
|
|
14
|
-
const capacityAmount = getCapacityAmount(error);
|
|
15
|
-
availableCapacity -= capacityAmount;
|
|
16
|
-
return capacityAmount;
|
|
17
|
-
};
|
|
18
|
-
const releaseRetryTokens = (capacityReleaseAmount) => {
|
|
19
|
-
availableCapacity += capacityReleaseAmount ?? noRetryIncrement;
|
|
20
|
-
availableCapacity = Math.min(availableCapacity, MAX_CAPACITY);
|
|
21
|
-
};
|
|
22
|
-
return Object.freeze({
|
|
23
|
-
hasRetryTokens,
|
|
24
|
-
retrieveRetryTokens,
|
|
25
|
-
releaseRetryTokens,
|
|
26
|
-
});
|
|
27
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { isClockSkewError, isRetryableByTrait, isThrottlingError, isTransientError, } from "@smithy/service-error-classification";
|
|
2
|
-
export const defaultRetryDecider = (error) => {
|
|
3
|
-
if (!error) {
|
|
4
|
-
return false;
|
|
5
|
-
}
|
|
6
|
-
return isRetryableByTrait(error) || isClockSkewError(error) || isThrottlingError(error) || isTransientError(error);
|
|
7
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { HttpRequest } from "@smithy/protocol-http";
|
|
2
|
-
import { isServerError, isThrottlingError, isTransientError } from "@smithy/service-error-classification";
|
|
3
|
-
import { NoOpLogger } from "@smithy/smithy-client";
|
|
4
|
-
import { INVOCATION_ID_HEADER, REQUEST_HEADER } from "@smithy/util-retry";
|
|
5
|
-
import { v4 } from "@smithy/uuid";
|
|
6
|
-
import { isStreamingPayload } from "./isStreamingPayload/isStreamingPayload";
|
|
7
|
-
import { parseRetryAfterHeader } from "./parseRetryAfterHeader";
|
|
8
|
-
import { asSdkError } from "./util";
|
|
9
|
-
export const retryMiddleware = (options) => (next, context) => async (args) => {
|
|
10
|
-
let retryStrategy = await options.retryStrategy();
|
|
11
|
-
const maxAttempts = await options.maxAttempts();
|
|
12
|
-
if (isRetryStrategyV2(retryStrategy)) {
|
|
13
|
-
retryStrategy = retryStrategy;
|
|
14
|
-
let retryToken = await retryStrategy.acquireInitialRetryToken((context["partition_id"] ?? "") + (context.__retryLongPoll ? ":longpoll" : ""));
|
|
15
|
-
let lastError = new Error();
|
|
16
|
-
let attempts = 0;
|
|
17
|
-
let totalRetryDelay = 0;
|
|
18
|
-
const { request } = args;
|
|
19
|
-
const isRequest = HttpRequest.isInstance(request);
|
|
20
|
-
if (isRequest) {
|
|
21
|
-
request.headers[INVOCATION_ID_HEADER] = v4();
|
|
22
|
-
}
|
|
23
|
-
while (true) {
|
|
24
|
-
try {
|
|
25
|
-
if (isRequest) {
|
|
26
|
-
request.headers[REQUEST_HEADER] = `attempt=${attempts + 1}; max=${maxAttempts}`;
|
|
27
|
-
}
|
|
28
|
-
const { response, output } = await next(args);
|
|
29
|
-
retryStrategy.recordSuccess(retryToken);
|
|
30
|
-
output.$metadata.attempts = attempts + 1;
|
|
31
|
-
output.$metadata.totalRetryDelay = totalRetryDelay;
|
|
32
|
-
return { response, output };
|
|
33
|
-
}
|
|
34
|
-
catch (e) {
|
|
35
|
-
const retryErrorInfo = getRetryErrorInfo(e, options.logger);
|
|
36
|
-
lastError = asSdkError(e);
|
|
37
|
-
if (isRequest && isStreamingPayload(request)) {
|
|
38
|
-
(context.logger instanceof NoOpLogger ? console : context.logger)?.warn("An error was encountered in a non-retryable streaming request.");
|
|
39
|
-
throw lastError;
|
|
40
|
-
}
|
|
41
|
-
try {
|
|
42
|
-
retryToken = await retryStrategy.refreshRetryTokenForRetry(retryToken, retryErrorInfo);
|
|
43
|
-
}
|
|
44
|
-
catch (refreshError) {
|
|
45
|
-
if (typeof refreshError.$backoff === "number") {
|
|
46
|
-
await cooldown(refreshError.$backoff);
|
|
47
|
-
}
|
|
48
|
-
if (!lastError.$metadata) {
|
|
49
|
-
lastError.$metadata = {};
|
|
50
|
-
}
|
|
51
|
-
lastError.$metadata.attempts = attempts + 1;
|
|
52
|
-
lastError.$metadata.totalRetryDelay = totalRetryDelay;
|
|
53
|
-
throw lastError;
|
|
54
|
-
}
|
|
55
|
-
attempts = retryToken.getRetryCount();
|
|
56
|
-
const delay = retryToken.getRetryDelay();
|
|
57
|
-
totalRetryDelay += delay;
|
|
58
|
-
await cooldown(delay);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
retryStrategy = retryStrategy;
|
|
64
|
-
if (retryStrategy?.mode) {
|
|
65
|
-
context.userAgent = [...(context.userAgent || []), ["cfg/retry-mode", retryStrategy.mode]];
|
|
66
|
-
}
|
|
67
|
-
return retryStrategy.retry(next, args);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
const cooldown = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
71
|
-
const isRetryStrategyV2 = (retryStrategy) => typeof retryStrategy.acquireInitialRetryToken !== "undefined" &&
|
|
72
|
-
typeof retryStrategy.refreshRetryTokenForRetry !== "undefined" &&
|
|
73
|
-
typeof retryStrategy.recordSuccess !== "undefined";
|
|
74
|
-
const getRetryErrorInfo = (error, logger) => {
|
|
75
|
-
const errorInfo = {
|
|
76
|
-
error,
|
|
77
|
-
errorType: getRetryErrorType(error),
|
|
78
|
-
};
|
|
79
|
-
const retryAfterHint = parseRetryAfterHeader(error.$response, logger);
|
|
80
|
-
if (retryAfterHint) {
|
|
81
|
-
errorInfo.retryAfterHint = retryAfterHint;
|
|
82
|
-
}
|
|
83
|
-
return errorInfo;
|
|
84
|
-
};
|
|
85
|
-
const getRetryErrorType = (error) => {
|
|
86
|
-
if (isThrottlingError(error))
|
|
87
|
-
return "THROTTLING";
|
|
88
|
-
if (isTransientError(error))
|
|
89
|
-
return "TRANSIENT";
|
|
90
|
-
if (isServerError(error))
|
|
91
|
-
return "SERVER_ERROR";
|
|
92
|
-
return "CLIENT_ERROR";
|
|
93
|
-
};
|
|
94
|
-
export const retryMiddlewareOptions = {
|
|
95
|
-
name: "retryMiddleware",
|
|
96
|
-
tags: ["RETRY"],
|
|
97
|
-
step: "finalizeRequest",
|
|
98
|
-
priority: "high",
|
|
99
|
-
override: true,
|
|
100
|
-
};
|
|
101
|
-
export const getRetryPlugin = (options) => ({
|
|
102
|
-
applyToStack: (clientStack) => {
|
|
103
|
-
clientStack.add(retryMiddleware(options), retryMiddlewareOptions);
|
|
104
|
-
},
|
|
105
|
-
});
|
package/dist-es/util.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export const asSdkError = (error) => {
|
|
2
|
-
if (error instanceof Error)
|
|
3
|
-
return error;
|
|
4
|
-
if (error instanceof Object)
|
|
5
|
-
return Object.assign(new Error(), error);
|
|
6
|
-
if (typeof error === "string")
|
|
7
|
-
return new Error(error);
|
|
8
|
-
return new Error(`AWS SDK error wrapper for ${error}`);
|
|
9
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { LoadedConfigSelectors } from "@smithy/node-config-provider";
|
|
2
|
-
import type { Logger, Provider, RetryStrategy, RetryStrategyV2 } from "@smithy/types";
|
|
3
|
-
/**
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
export declare const ENV_MAX_ATTEMPTS = "AWS_MAX_ATTEMPTS";
|
|
7
|
-
/**
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export declare const CONFIG_MAX_ATTEMPTS = "max_attempts";
|
|
11
|
-
/**
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
export declare const NODE_MAX_ATTEMPT_CONFIG_OPTIONS: LoadedConfigSelectors<number>;
|
|
15
|
-
/**
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
|
-
export interface RetryInputConfig {
|
|
19
|
-
/**
|
|
20
|
-
* The maximum number of times requests that encounter retryable failures should be attempted.
|
|
21
|
-
*/
|
|
22
|
-
maxAttempts?: number | Provider<number>;
|
|
23
|
-
/**
|
|
24
|
-
* The strategy to retry the request. Using built-in exponential backoff strategy by default.
|
|
25
|
-
*/
|
|
26
|
-
retryStrategy?: RetryStrategy | RetryStrategyV2;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
export interface PreviouslyResolved {
|
|
32
|
-
/**
|
|
33
|
-
* Specifies provider for retry algorithm to use.
|
|
34
|
-
* @internal
|
|
35
|
-
*/
|
|
36
|
-
retryMode: string | Provider<string>;
|
|
37
|
-
logger?: Logger;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* @internal
|
|
41
|
-
*/
|
|
42
|
-
export interface RetryResolvedConfig {
|
|
43
|
-
/**
|
|
44
|
-
* Resolved value for input config {@link RetryInputConfig.maxAttempts}
|
|
45
|
-
*/
|
|
46
|
-
maxAttempts: Provider<number>;
|
|
47
|
-
/**
|
|
48
|
-
* Resolved value for input config {@link RetryInputConfig.retryStrategy}
|
|
49
|
-
*/
|
|
50
|
-
retryStrategy: Provider<RetryStrategyV2 | RetryStrategy>;
|
|
51
|
-
logger?: Logger;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* @internal
|
|
55
|
-
*/
|
|
56
|
-
export declare const resolveRetryConfig: <T>(input: T & PreviouslyResolved & RetryInputConfig) => T & RetryResolvedConfig;
|
|
57
|
-
/**
|
|
58
|
-
* @internal
|
|
59
|
-
*/
|
|
60
|
-
export declare const ENV_RETRY_MODE = "AWS_RETRY_MODE";
|
|
61
|
-
/**
|
|
62
|
-
* @internal
|
|
63
|
-
*/
|
|
64
|
-
export declare const CONFIG_RETRY_MODE = "retry_mode";
|
|
65
|
-
/**
|
|
66
|
-
* @internal
|
|
67
|
-
*/
|
|
68
|
-
export declare const NODE_RETRY_MODE_CONFIG_OPTIONS: LoadedConfigSelectors<string>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { HandlerExecutionContext, InitializeHandler, InitializeHandlerOptions, MetadataBearer, Pluggable } from "@smithy/types";
|
|
2
|
-
import type { RetryResolvedConfig } from "./configurations";
|
|
3
|
-
/**
|
|
4
|
-
* This middleware is attached to operations designated as long-polling.
|
|
5
|
-
* @internal
|
|
6
|
-
*/
|
|
7
|
-
export declare const longPollMiddleware: () => <Output extends MetadataBearer = MetadataBearer>(next: InitializeHandler<any, Output>, context: HandlerExecutionContext) => InitializeHandler<any, Output>;
|
|
8
|
-
/**
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
export declare const longPollMiddlewareOptions: InitializeHandlerOptions;
|
|
12
|
-
/**
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
export declare const getLongPollPlugin: (options: RetryResolvedConfig) => Pluggable<any, any>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { FinalizeHandler, MetadataBearer, Pluggable, RelativeMiddlewareOptions } from "@smithy/types";
|
|
2
|
-
/**
|
|
3
|
-
* This is still in use.
|
|
4
|
-
* See AddOmitRetryHeadersDependency.java.
|
|
5
|
-
* @internal
|
|
6
|
-
*/
|
|
7
|
-
export declare const omitRetryHeadersMiddleware: () => <Output extends MetadataBearer = MetadataBearer>(next: FinalizeHandler<any, Output>) => FinalizeHandler<any, Output>;
|
|
8
|
-
/**
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
export declare const omitRetryHeadersMiddlewareOptions: RelativeMiddlewareOptions;
|
|
12
|
-
/**
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
export declare const getOmitRetryHeadersPlugin: (options: unknown) => Pluggable<any, any>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Logger } from "@smithy/types";
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export declare function parseRetryAfterHeader(response: unknown, logger?: Logger): Date | undefined;
|
|
6
|
-
/**
|
|
7
|
-
* Backwards-compatibility alias.
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export declare function getRetryAfterHint(response: unknown, logger?: Logger): Date | undefined;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { FinalizeHandler, FinalizeHandlerArguments, MetadataBearer, Provider } from "@smithy/types";
|
|
2
|
-
import type { RateLimiter } from "@smithy/util-retry";
|
|
3
|
-
import type { StandardRetryStrategyOptions } from "./StandardRetryStrategy";
|
|
4
|
-
import { StandardRetryStrategy } from "./StandardRetryStrategy";
|
|
5
|
-
/**
|
|
6
|
-
* Strategy options to be passed to AdaptiveRetryStrategy
|
|
7
|
-
* @public
|
|
8
|
-
* @deprecated replaced by \@smithy/util-retry (SRA).
|
|
9
|
-
*/
|
|
10
|
-
export interface AdaptiveRetryStrategyOptions extends StandardRetryStrategyOptions {
|
|
11
|
-
rateLimiter?: RateLimiter;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* @public
|
|
15
|
-
* @deprecated use AdaptiveRetryStrategy from @smithy/util-retry
|
|
16
|
-
*/
|
|
17
|
-
export declare class AdaptiveRetryStrategy extends StandardRetryStrategy {
|
|
18
|
-
private rateLimiter;
|
|
19
|
-
constructor(maxAttemptsProvider: Provider<number>, options?: AdaptiveRetryStrategyOptions);
|
|
20
|
-
retry<Input extends object, Ouput extends MetadataBearer>(next: FinalizeHandler<Input, Ouput>, args: FinalizeHandlerArguments<Input>): Promise<{
|
|
21
|
-
response: unknown;
|
|
22
|
-
output: Ouput;
|
|
23
|
-
}>;
|
|
24
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { FinalizeHandler, FinalizeHandlerArguments, MetadataBearer, Provider, RetryStrategy } from "@smithy/types";
|
|
2
|
-
import type { DelayDecider, RetryDecider, RetryQuota } from "./types";
|
|
3
|
-
/**
|
|
4
|
-
* Strategy options to be passed to StandardRetryStrategy
|
|
5
|
-
* @public
|
|
6
|
-
* @deprecated use StandardRetryStrategy from @smithy/util-retry
|
|
7
|
-
*/
|
|
8
|
-
export interface StandardRetryStrategyOptions {
|
|
9
|
-
retryDecider?: RetryDecider;
|
|
10
|
-
delayDecider?: DelayDecider;
|
|
11
|
-
retryQuota?: RetryQuota;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* @public
|
|
15
|
-
* @deprecated use StandardRetryStrategy from @smithy/util-retry
|
|
16
|
-
*/
|
|
17
|
-
export declare class StandardRetryStrategy implements RetryStrategy {
|
|
18
|
-
private readonly maxAttemptsProvider;
|
|
19
|
-
private retryDecider;
|
|
20
|
-
private delayDecider;
|
|
21
|
-
private retryQuota;
|
|
22
|
-
mode: string;
|
|
23
|
-
constructor(maxAttemptsProvider: Provider<number>, options?: StandardRetryStrategyOptions);
|
|
24
|
-
private shouldRetry;
|
|
25
|
-
private getMaxAttempts;
|
|
26
|
-
retry<Input extends object, Ouput extends MetadataBearer>(next: FinalizeHandler<Input, Ouput>, args: FinalizeHandlerArguments<Input>, options?: {
|
|
27
|
-
beforeRequest: Function;
|
|
28
|
-
afterRequest: Function;
|
|
29
|
-
}): Promise<{
|
|
30
|
-
response: unknown;
|
|
31
|
-
output: Ouput;
|
|
32
|
-
}>;
|
|
33
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { RetryQuota } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
* @deprecated replaced by \@smithy/util-retry (SRA).
|
|
5
|
-
*/
|
|
6
|
-
export interface DefaultRetryQuotaOptions {
|
|
7
|
-
/**
|
|
8
|
-
* The total amount of retry token to be incremented from retry token balance
|
|
9
|
-
* if an SDK operation invocation succeeds without requiring a retry request.
|
|
10
|
-
*/
|
|
11
|
-
noRetryIncrement?: number;
|
|
12
|
-
/**
|
|
13
|
-
* The total amount of retry tokens to be decremented from retry token balance.
|
|
14
|
-
*/
|
|
15
|
-
retryCost?: number;
|
|
16
|
-
/**
|
|
17
|
-
* The total amount of retry tokens to be decremented from retry token balance
|
|
18
|
-
* when a throttling error is encountered.
|
|
19
|
-
*/
|
|
20
|
-
timeoutRetryCost?: number;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* @internal
|
|
24
|
-
* @deprecated replaced by \@smithy/util-retry (SRA).
|
|
25
|
-
*/
|
|
26
|
-
export declare const getDefaultRetryQuota: (initialRetryTokens: number, options?: DefaultRetryQuotaOptions) => RetryQuota;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { SdkError } from "@smithy/types";
|
|
2
|
-
/**
|
|
3
|
-
* Determines whether an error is retryable based on the number of retries
|
|
4
|
-
* already attempted, the HTTP status code, and the error received (if any).
|
|
5
|
-
*
|
|
6
|
-
* @param error - The error encountered.
|
|
7
|
-
*
|
|
8
|
-
* @deprecated
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
export interface RetryDecider {
|
|
12
|
-
(error: SdkError): boolean;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Determines the number of milliseconds to wait before retrying an action.
|
|
16
|
-
*
|
|
17
|
-
* @param delayBase - The base delay (in milliseconds).
|
|
18
|
-
* @param attempts - The number of times the action has already been tried.
|
|
19
|
-
*
|
|
20
|
-
* @deprecated
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
export interface DelayDecider {
|
|
24
|
-
(delayBase: number, attempts: number): number;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Interface that specifies the retry quota behavior.
|
|
28
|
-
* @deprecated
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
export interface RetryQuota {
|
|
32
|
-
/**
|
|
33
|
-
* returns true if retry tokens are available from the retry quota bucket.
|
|
34
|
-
*/
|
|
35
|
-
hasRetryTokens: (error: SdkError) => boolean;
|
|
36
|
-
/**
|
|
37
|
-
* returns token amount from the retry quota bucket.
|
|
38
|
-
* throws error is retry tokens are not available.
|
|
39
|
-
*/
|
|
40
|
-
retrieveRetryTokens: (error: SdkError) => number;
|
|
41
|
-
/**
|
|
42
|
-
* releases tokens back to the retry quota.
|
|
43
|
-
*/
|
|
44
|
-
releaseRetryTokens: (releaseCapacityAmount?: number) => void;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* @deprecated
|
|
48
|
-
* @internal
|
|
49
|
-
*/
|
|
50
|
-
export interface RateLimiter {
|
|
51
|
-
/**
|
|
52
|
-
* If there is sufficient capacity (tokens) available, it immediately returns.
|
|
53
|
-
* If there is not sufficient capacity, it will either sleep a certain amount
|
|
54
|
-
* of time until the rate limiter can retrieve a token from its token bucket
|
|
55
|
-
* or raise an exception indicating there is insufficient capacity.
|
|
56
|
-
*/
|
|
57
|
-
getSendToken: () => Promise<void>;
|
|
58
|
-
/**
|
|
59
|
-
* Updates the client sending rate based on response.
|
|
60
|
-
* If the response was successful, the capacity and fill rate are increased.
|
|
61
|
-
* If the response was a throttling response, the capacity and fill rate are
|
|
62
|
-
* decreased. Transient errors do not affect the rate limiter.
|
|
63
|
-
*/
|
|
64
|
-
updateClientSendingRate: (response: any) => void;
|
|
65
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { AbsoluteLocation, FinalizeHandler, FinalizeRequestHandlerOptions, HandlerExecutionContext, MetadataBearer, Pluggable } from "@smithy/types";
|
|
2
|
-
import type { RetryResolvedConfig } from "./configurations";
|
|
3
|
-
/**
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
export declare const retryMiddleware: (options: RetryResolvedConfig) => <Output extends MetadataBearer = MetadataBearer>(next: FinalizeHandler<any, Output>, context: HandlerExecutionContext) => FinalizeHandler<any, Output>;
|
|
7
|
-
/**
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export declare const retryMiddlewareOptions: FinalizeRequestHandlerOptions & AbsoluteLocation;
|
|
11
|
-
/**
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
export declare const getRetryPlugin: (options: RetryResolvedConfig) => Pluggable<any, any>;
|
package/dist-types/util.d.ts
DELETED