Skip to content

chore(middleware-retry): move exportable constants to configurations #2442

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/middleware-retry/src/configurations.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {
CONFIG_MAX_ATTEMPTS,
DEFAULT_MAX_ATTEMPTS,
ENV_MAX_ATTEMPTS,
NODE_MAX_ATTEMPT_CONFIG_OPTIONS,
resolveRetryConfig,
} from "./configurations";
import { DEFAULT_MAX_ATTEMPTS, StandardRetryStrategy } from "./defaultStrategy";
import { StandardRetryStrategy } from "./defaultStrategy";

jest.mock("./defaultStrategy");

Expand Down
13 changes: 12 additions & 1 deletion packages/middleware-retry/src/configurations.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import { LoadedConfigSelectors } from "@aws-sdk/node-config-provider";
import { Provider, RetryStrategy } from "@aws-sdk/types";

import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE, StandardRetryStrategy } from "./defaultStrategy";
import { StandardRetryStrategy } from "./defaultStrategy";

export const ENV_MAX_ATTEMPTS = "AWS_MAX_ATTEMPTS";
export const CONFIG_MAX_ATTEMPTS = "max_attempts";

/**
* The default value for how many HTTP requests an SDK should make for a
* single SDK operation invocation before giving up
*/
export const DEFAULT_MAX_ATTEMPTS = 3;

/**
* The default retry algorithm to use.
*/
export const DEFAULT_RETRY_MODE = "standard";

export const NODE_MAX_ATTEMPT_CONFIG_OPTIONS: LoadedConfigSelectors<number> = {
environmentVariableSelector: (env) => {
const value = env[ENV_MAX_ATTEMPTS];
Expand Down
3 changes: 2 additions & 1 deletion packages/middleware-retry/src/defaultStrategy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { HttpRequest } from "@aws-sdk/protocol-http";
import { isThrottlingError } from "@aws-sdk/service-error-classification";
import { v4 } from "uuid";

import { DEFAULT_MAX_ATTEMPTS } from "./configurations";
import { DEFAULT_RETRY_DELAY_BASE, INITIAL_RETRY_TOKENS, THROTTLING_RETRY_DELAY_BASE } from "./constants";
import { getDefaultRetryQuota } from "./defaultRetryQuota";
import { DEFAULT_MAX_ATTEMPTS, StandardRetryStrategy } from "./defaultStrategy";
import { StandardRetryStrategy } from "./defaultStrategy";
import { defaultDelayDecider } from "./delayDecider";
import { defaultRetryDecider } from "./retryDecider";
import { RetryQuota } from "./types";
Expand Down
12 changes: 1 addition & 11 deletions packages/middleware-retry/src/defaultStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { SdkError } from "@aws-sdk/smithy-client";
import { FinalizeHandler, FinalizeHandlerArguments, MetadataBearer, Provider, RetryStrategy } from "@aws-sdk/types";
import { v4 } from "uuid";

import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "./configurations";
import {
DEFAULT_RETRY_DELAY_BASE,
INITIAL_RETRY_TOKENS,
Expand All @@ -16,17 +17,6 @@ import { defaultDelayDecider } from "./delayDecider";
import { defaultRetryDecider } from "./retryDecider";
import { DelayDecider, RetryDecider, RetryQuota } from "./types";

/**
* The default value for how many HTTP requests an SDK should make for a
* single SDK operation invocation before giving up
*/
export const DEFAULT_MAX_ATTEMPTS = 3;

/**
* The default retry algorithm to use.
*/
export const DEFAULT_RETRY_MODE = "standard";

/**
* Strategy options to be passed to StandardRetryStrategy
*/
Expand Down