Skip to content

Commit e2fd6e3

Browse files
authored
chore(middleware-retry): move exportable constants to configurations (#2442)
1 parent 30af3f2 commit e2fd6e3

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

packages/middleware-retry/src/configurations.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import {
22
CONFIG_MAX_ATTEMPTS,
3+
DEFAULT_MAX_ATTEMPTS,
34
ENV_MAX_ATTEMPTS,
45
NODE_MAX_ATTEMPT_CONFIG_OPTIONS,
56
resolveRetryConfig,
67
} from "./configurations";
7-
import { DEFAULT_MAX_ATTEMPTS, StandardRetryStrategy } from "./defaultStrategy";
8+
import { StandardRetryStrategy } from "./defaultStrategy";
89

910
jest.mock("./defaultStrategy");
1011

packages/middleware-retry/src/configurations.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
import { LoadedConfigSelectors } from "@aws-sdk/node-config-provider";
22
import { Provider, RetryStrategy } from "@aws-sdk/types";
33

4-
import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE, StandardRetryStrategy } from "./defaultStrategy";
4+
import { StandardRetryStrategy } from "./defaultStrategy";
55

66
export const ENV_MAX_ATTEMPTS = "AWS_MAX_ATTEMPTS";
77
export const CONFIG_MAX_ATTEMPTS = "max_attempts";
88

9+
/**
10+
* The default value for how many HTTP requests an SDK should make for a
11+
* single SDK operation invocation before giving up
12+
*/
13+
export const DEFAULT_MAX_ATTEMPTS = 3;
14+
15+
/**
16+
* The default retry algorithm to use.
17+
*/
18+
export const DEFAULT_RETRY_MODE = "standard";
19+
920
export const NODE_MAX_ATTEMPT_CONFIG_OPTIONS: LoadedConfigSelectors<number> = {
1021
environmentVariableSelector: (env) => {
1122
const value = env[ENV_MAX_ATTEMPTS];

packages/middleware-retry/src/defaultStrategy.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import { HttpRequest } from "@aws-sdk/protocol-http";
22
import { isThrottlingError } from "@aws-sdk/service-error-classification";
33
import { v4 } from "uuid";
44

5+
import { DEFAULT_MAX_ATTEMPTS } from "./configurations";
56
import { DEFAULT_RETRY_DELAY_BASE, INITIAL_RETRY_TOKENS, THROTTLING_RETRY_DELAY_BASE } from "./constants";
67
import { getDefaultRetryQuota } from "./defaultRetryQuota";
7-
import { DEFAULT_MAX_ATTEMPTS, StandardRetryStrategy } from "./defaultStrategy";
8+
import { StandardRetryStrategy } from "./defaultStrategy";
89
import { defaultDelayDecider } from "./delayDecider";
910
import { defaultRetryDecider } from "./retryDecider";
1011
import { RetryQuota } from "./types";

packages/middleware-retry/src/defaultStrategy.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { SdkError } from "@aws-sdk/smithy-client";
44
import { FinalizeHandler, FinalizeHandlerArguments, MetadataBearer, Provider, RetryStrategy } from "@aws-sdk/types";
55
import { v4 } from "uuid";
66

7+
import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "./configurations";
78
import {
89
DEFAULT_RETRY_DELAY_BASE,
910
INITIAL_RETRY_TOKENS,
@@ -16,17 +17,6 @@ import { defaultDelayDecider } from "./delayDecider";
1617
import { defaultRetryDecider } from "./retryDecider";
1718
import { DelayDecider, RetryDecider, RetryQuota } from "./types";
1819

19-
/**
20-
* The default value for how many HTTP requests an SDK should make for a
21-
* single SDK operation invocation before giving up
22-
*/
23-
export const DEFAULT_MAX_ATTEMPTS = 3;
24-
25-
/**
26-
* The default retry algorithm to use.
27-
*/
28-
export const DEFAULT_RETRY_MODE = "standard";
29-
3020
/**
3121
* Strategy options to be passed to StandardRetryStrategy
3222
*/

0 commit comments

Comments
 (0)