@tramvai/tinkoff-request-http-client-adapter 0.8.336 → 0.8.337

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.
@@ -25,6 +25,11 @@ export interface TinkoffRequestOptions extends HttpClientBaseOptions {
25
25
  maxAge: number;
26
26
  max: number;
27
27
  };
28
+ retryOptions?: {
29
+ retry?: number;
30
+ retryDelay?: number | ((attempt: number) => number);
31
+ maxTimeout?: number;
32
+ };
28
33
  agent?: {
29
34
  http: Agent;
30
35
  https: Agent;
@@ -7,6 +7,7 @@ import validate from '@tinkoff/request-plugin-validate';
7
7
  import http, { isServerError, isNetworkFail, getStatus, getHeaders } from '@tinkoff/request-plugin-protocol-http';
8
8
  import transformUrl from '@tinkoff/request-plugin-transform-url';
9
9
  import circuitBreaker from '@tinkoff/request-plugin-circuit-breaker';
10
+ import retry from '@tinkoff/request-plugin-retry';
10
11
  import { BaseHttpClient } from '@tramvai/http-client';
11
12
  import compose from '@tinkoff/utils/function/compose';
12
13
 
@@ -14,7 +15,7 @@ const createAgent = () => { };
14
15
 
15
16
  const defaultAgent = createAgent();
16
17
  function createTinkoffRequest(options) {
17
- const { logger, name, disableCache, enableCircuitBreaker, createCache, cacheTime = 30000, defaultTimeout, validator, errorValidator, errorModificator, circuitBreakerOptions = {}, getCacheKey, lruOptions = { max: 1000, maxAge: cacheTime }, agent, ...defaults } = options;
18
+ const { logger, name, disableCache, enableCircuitBreaker, createCache, cacheTime = 30000, defaultTimeout, validator, errorValidator, errorModificator, circuitBreakerOptions = {}, getCacheKey, lruOptions = { max: 1000, maxAge: cacheTime }, agent, retryOptions, ...defaults } = options;
18
19
  const log = logger && logger(`${name}:initialization`);
19
20
  const plugins = [];
20
21
  plugins.push({
@@ -97,6 +98,9 @@ function createTinkoffRequest(options) {
97
98
  }));
98
99
  }
99
100
  plugins.push(http({ agent: agent || defaultAgent }));
101
+ if (retryOptions) {
102
+ plugins.push(retry(retryOptions));
103
+ }
100
104
  const makeRequest = request(plugins);
101
105
  return makeRequest;
102
106
  }
package/lib/index.es.js CHANGED
@@ -7,6 +7,7 @@ import validate from '@tinkoff/request-plugin-validate';
7
7
  import http$1, { isServerError, isNetworkFail, getStatus, getHeaders } from '@tinkoff/request-plugin-protocol-http';
8
8
  import transformUrl from '@tinkoff/request-plugin-transform-url';
9
9
  import circuitBreaker from '@tinkoff/request-plugin-circuit-breaker';
10
+ import retry from '@tinkoff/request-plugin-retry';
10
11
  import http from 'http';
11
12
  import https from 'https';
12
13
  import { BaseHttpClient } from '@tramvai/http-client';
@@ -24,7 +25,7 @@ const createAgent = (options = {
24
25
 
25
26
  const defaultAgent = createAgent();
26
27
  function createTinkoffRequest(options) {
27
- const { logger, name, disableCache, enableCircuitBreaker, createCache, cacheTime = 30000, defaultTimeout, validator, errorValidator, errorModificator, circuitBreakerOptions = {}, getCacheKey, lruOptions = { max: 1000, maxAge: cacheTime }, agent, ...defaults } = options;
28
+ const { logger, name, disableCache, enableCircuitBreaker, createCache, cacheTime = 30000, defaultTimeout, validator, errorValidator, errorModificator, circuitBreakerOptions = {}, getCacheKey, lruOptions = { max: 1000, maxAge: cacheTime }, agent, retryOptions, ...defaults } = options;
28
29
  const log = logger && logger(`${name}:initialization`);
29
30
  const plugins = [];
30
31
  plugins.push({
@@ -107,6 +108,9 @@ function createTinkoffRequest(options) {
107
108
  }));
108
109
  }
109
110
  plugins.push(http$1({ agent: agent || defaultAgent }));
111
+ if (retryOptions) {
112
+ plugins.push(retry(retryOptions));
113
+ }
110
114
  const makeRequest = request(plugins);
111
115
  return makeRequest;
112
116
  }
package/lib/index.js CHANGED
@@ -11,6 +11,7 @@ var validate = require('@tinkoff/request-plugin-validate');
11
11
  var http$1 = require('@tinkoff/request-plugin-protocol-http');
12
12
  var transformUrl = require('@tinkoff/request-plugin-transform-url');
13
13
  var circuitBreaker = require('@tinkoff/request-plugin-circuit-breaker');
14
+ var retry = require('@tinkoff/request-plugin-retry');
14
15
  var http = require('http');
15
16
  var https = require('https');
16
17
  var httpClient = require('@tramvai/http-client');
@@ -27,6 +28,7 @@ var validate__default = /*#__PURE__*/_interopDefaultLegacy(validate);
27
28
  var http__default$1 = /*#__PURE__*/_interopDefaultLegacy(http$1);
28
29
  var transformUrl__default = /*#__PURE__*/_interopDefaultLegacy(transformUrl);
29
30
  var circuitBreaker__default = /*#__PURE__*/_interopDefaultLegacy(circuitBreaker);
31
+ var retry__default = /*#__PURE__*/_interopDefaultLegacy(retry);
30
32
  var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
31
33
  var https__default = /*#__PURE__*/_interopDefaultLegacy(https);
32
34
  var compose__default = /*#__PURE__*/_interopDefaultLegacy(compose);
@@ -43,7 +45,7 @@ const createAgent = (options = {
43
45
 
44
46
  const defaultAgent = createAgent();
45
47
  function createTinkoffRequest(options) {
46
- const { logger, name, disableCache, enableCircuitBreaker, createCache, cacheTime = 30000, defaultTimeout, validator, errorValidator, errorModificator, circuitBreakerOptions = {}, getCacheKey, lruOptions = { max: 1000, maxAge: cacheTime }, agent, ...defaults } = options;
48
+ const { logger, name, disableCache, enableCircuitBreaker, createCache, cacheTime = 30000, defaultTimeout, validator, errorValidator, errorModificator, circuitBreakerOptions = {}, getCacheKey, lruOptions = { max: 1000, maxAge: cacheTime }, agent, retryOptions, ...defaults } = options;
47
49
  const log = logger && logger(`${name}:initialization`);
48
50
  const plugins = [];
49
51
  plugins.push({
@@ -126,6 +128,9 @@ function createTinkoffRequest(options) {
126
128
  }));
127
129
  }
128
130
  plugins.push(http__default$1["default"]({ agent: agent || defaultAgent }));
131
+ if (retryOptions) {
132
+ plugins.push(retry__default["default"](retryOptions));
133
+ }
129
134
  const makeRequest = request__default["default"](plugins);
130
135
  return makeRequest;
131
136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/tinkoff-request-http-client-adapter",
3
- "version": "0.8.336",
3
+ "version": "0.8.337",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "browser": {
@@ -29,9 +29,10 @@
29
29
  "@tinkoff/request-plugin-protocol-http": "^0.10.18",
30
30
  "@tinkoff/request-plugin-transform-url": "^0.8.8",
31
31
  "@tinkoff/request-plugin-validate": "^0.8.8",
32
+ "@tinkoff/request-plugin-retry": "^0.2.3",
32
33
  "@tinkoff/utils": "^2.1.2",
33
34
  "@tramvai/http-client": "0.1.25",
34
- "@tramvai/tokens-common": "1.97.0",
35
+ "@tramvai/tokens-common": "1.98.0",
35
36
  "tslib": "^2.0.3"
36
37
  },
37
38
  "sideEffects": false,