Socket
Socket
Sign inDemoInstall

@aws-sdk/util-retry

Package Overview
Dependencies
Maintainers
5
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-sdk/util-retry - npm Package Compare versions

Comparing version 3.327.0 to 3.329.0

dist-cjs/ConfiguredRetryStrategy.js

2

dist-cjs/config.js

@@ -10,2 +10,2 @@ "use strict";

exports.DEFAULT_MAX_ATTEMPTS = 3;
exports.DEFAULT_RETRY_MODE = "STANDARD";
exports.DEFAULT_RETRY_MODE = RETRY_MODES.STANDARD;

@@ -5,2 +5,3 @@ "use strict";

tslib_1.__exportStar(require("./AdaptiveRetryStrategy"), exports);
tslib_1.__exportStar(require("./ConfiguredRetryStrategy"), exports);
tslib_1.__exportStar(require("./DefaultRateLimiter"), exports);

@@ -7,0 +8,0 @@ tslib_1.__exportStar(require("./StandardRetryStrategy"), exports);

@@ -8,7 +8,7 @@ "use strict";

class StandardRetryStrategy {
constructor(maxAttemptsProvider) {
this.maxAttemptsProvider = maxAttemptsProvider;
constructor(maxAttempts) {
this.maxAttempts = maxAttempts;
this.mode = config_1.RETRY_MODES.STANDARD;
this.retryToken = (0, defaultRetryToken_1.getDefaultRetryToken)(constants_1.INITIAL_RETRY_TOKENS, constants_1.DEFAULT_RETRY_DELAY_BASE);
this.maxAttemptsProvider = maxAttemptsProvider;
this.maxAttemptsProvider = typeof maxAttempts === "function" ? maxAttempts : async () => maxAttempts;
}

@@ -15,0 +15,0 @@ async acquireInitialRetryToken(retryTokenScope) {

@@ -7,2 +7,2 @@ export var RETRY_MODES;

export const DEFAULT_MAX_ATTEMPTS = 3;
export const DEFAULT_RETRY_MODE = "STANDARD";
export const DEFAULT_RETRY_MODE = RETRY_MODES.STANDARD;
export * from "./AdaptiveRetryStrategy";
export * from "./ConfiguredRetryStrategy";
export * from "./DefaultRateLimiter";

@@ -3,0 +4,0 @@ export * from "./StandardRetryStrategy";

@@ -5,7 +5,7 @@ import { DEFAULT_MAX_ATTEMPTS, RETRY_MODES } from "./config";

export class StandardRetryStrategy {
constructor(maxAttemptsProvider) {
this.maxAttemptsProvider = maxAttemptsProvider;
constructor(maxAttempts) {
this.maxAttempts = maxAttempts;
this.mode = RETRY_MODES.STANDARD;
this.retryToken = getDefaultRetryToken(INITIAL_RETRY_TOKENS, DEFAULT_RETRY_DELAY_BASE);
this.maxAttemptsProvider = maxAttemptsProvider;
this.maxAttemptsProvider = typeof maxAttempts === "function" ? maxAttempts : async () => maxAttempts;
}

@@ -12,0 +12,0 @@ async acquireInitialRetryToken(retryTokenScope) {

import { Provider, RetryErrorInfo, RetryStrategyV2, RetryToken, StandardRetryToken } from "@aws-sdk/types";
import { RateLimiter } from "./types";
/**
* @internal
* @public
*

@@ -12,3 +12,3 @@ * Strategy options to be passed to AdaptiveRetryStrategy

/**
* @internal
* @public
*

@@ -15,0 +15,0 @@ * The AdaptiveRetryStrategy is a retry strategy for executing against a very

/**
* @internal
* @public
*/

@@ -9,3 +9,3 @@ export declare enum RETRY_MODES {

/**
* @internal
* @public
*

@@ -17,6 +17,6 @@ * The default value for how many HTTP requests an SDK should make for a

/**
* @internal
* @public
*
* The default retry algorithm to use.
*/
export declare const DEFAULT_RETRY_MODE: RETRY_MODES;
export declare const DEFAULT_RETRY_MODE = RETRY_MODES.STANDARD;
/**
* @internal
* @public
*

@@ -9,3 +9,3 @@ * The base number of milliseconds to use in calculating a suitable cool-down

/**
* @internal
* @public
*

@@ -17,3 +17,3 @@ * The maximum amount of time (in milliseconds) that will be used as a delay

/**
* @internal
* @public
*

@@ -25,3 +25,3 @@ * The retry delay base (in milliseconds) to use when a throttling error is

/**
* @internal
* @public
*

@@ -32,3 +32,3 @@ * Initial number of retry tokens in Retry Quota

/**
* @internal
* @public
*

@@ -39,3 +39,3 @@ * The total amount of retry tokens to be decremented from retry token balance.

/**
* @internal
* @public
*

@@ -47,3 +47,3 @@ * The total amount of retry tokens to be decremented from retry token balance

/**
* @internal
* @public
*

@@ -55,3 +55,3 @@ * The total amount of retry token to be incremented from retry token balance

/**
* @internal
* @public
*

@@ -62,3 +62,3 @@ * Header name for SDK invocation ID

/**
* @internal
* @public
*

@@ -65,0 +65,0 @@ * Header name for request retry information.

import { RateLimiter } from "./types";
/**
* @internal
* @public
*/

@@ -13,3 +13,3 @@ export interface DefaultRateLimiterOptions {

/**
* @internal
* @public
*/

@@ -16,0 +16,0 @@ export declare class DefaultRateLimiter implements RateLimiter {

import { StandardRetryBackoffStrategy, StandardRetryToken } from "@aws-sdk/types";
/**
* @internal
* @public
*/

@@ -5,0 +5,0 @@ export interface DefaultRetryTokenOptions {

@@ -1,24 +0,7 @@

/**
* @internal
*/
export * from "./AdaptiveRetryStrategy";
/**
* @internal
*/
export * from "./ConfiguredRetryStrategy";
export * from "./DefaultRateLimiter";
/**
* @internal
*/
export * from "./StandardRetryStrategy";
/**
* @internal
*/
export * from "./config";
/**
* @internal
*/
export * from "./constants";
/**
* @internal
*/
export * from "./types";
import { Provider, RetryErrorInfo, RetryStrategyV2, StandardRetryToken } from "@aws-sdk/types";
/**
* @internal
* @public
*/
export declare class StandardRetryStrategy implements RetryStrategyV2 {
private readonly maxAttempts;
readonly mode: string;
private retryToken;
private readonly maxAttemptsProvider;
private retryToken;
readonly mode: string;
constructor(maxAttempts: number);
constructor(maxAttemptsProvider: Provider<number>);

@@ -10,0 +12,0 @@ acquireInitialRetryToken(retryTokenScope: string): Promise<StandardRetryToken>;

@@ -6,2 +6,2 @@ export declare enum RETRY_MODES {

export declare const DEFAULT_MAX_ATTEMPTS = 3;
export declare const DEFAULT_RETRY_MODE: RETRY_MODES;
export declare const DEFAULT_RETRY_MODE = RETRY_MODES.STANDARD;
export * from "./AdaptiveRetryStrategy";
export * from "./ConfiguredRetryStrategy";
export * from "./DefaultRateLimiter";

@@ -3,0 +4,0 @@ export * from "./StandardRetryStrategy";

@@ -8,5 +8,7 @@ import {

export declare class StandardRetryStrategy implements RetryStrategyV2 {
private readonly maxAttempts;
readonly mode: string;
private retryToken;
private readonly maxAttemptsProvider;
private retryToken;
readonly mode: string;
constructor(maxAttempts: number);
constructor(maxAttemptsProvider: Provider<number>);

@@ -13,0 +15,0 @@ acquireInitialRetryToken(

{
"name": "@aws-sdk/util-retry",
"version": "3.327.0",
"version": "3.329.0",
"description": "Shared retry utilities to be used in middleware packages.",

@@ -27,7 +27,7 @@ "main": "./dist-cjs/index.js",

"dependencies": {
"@aws-sdk/service-error-classification": "3.327.0",
"@aws-sdk/service-error-classification": "3.329.0",
"tslib": "^2.5.0"
},
"devDependencies": {
"@aws-sdk/types": "3.310.0",
"@aws-sdk/types": "3.329.0",
"@tsconfig/recommended": "1.0.1",

@@ -34,0 +34,0 @@ "@types/node": "^14.14.31",

@@ -6,4 +6,2 @@ # @aws-sdk/util-retry

> An internal package
This package provides shared utilities for retries.

@@ -13,2 +11,55 @@

You probably shouldn't, at least directly.
### Default
By default, each client already has a default retry strategy. The default retry count is 3, and
only retryable errors will be retried.
[AWS Documentation: Retry behavior](https://docs.aws.amazon.com/sdkref/latest/guide/feature-retry-behavior.html).
```js
import { S3Client } from "@aws-sdk/client-s3";
const client = new S3Client({}); // default retry strategy included.
```
### MaxAttempts
If you want to change the number of attempts, you can use the `StandardRetryStrategy` from `@aws-sdk/util-retry`.
```js
import { S3Client } from "@aws-sdk/client-s3";
import { StandardRetryStrategy } from "@aws-sdk/util-retry";
const client = new S3Client({
// custom max number of attempts.
retryStrategy: new StandardRetryStrategy(4),
});
```
This is recommended because the `StandardRetryStrategy` includes backoff calculation,
deciding whether an error should be retried, and a retry token counter.
### MaxAttempts and BackoffComputation
If you want to change the number of attempts and use a custom delay
computation, you can use the `ConfiguredRetryStrategy` from `@aws-sdk/util-retry`.
```js
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.
),
});
```
This example sets the backoff at 100ms plus 1s per attempt.
### Further customization
You can implement the `RetryStrategyV2` interface.
https://github.com/aws/aws-sdk-js-v3/blob/main/packages/types/src/retry.ts
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc