You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
***API_RETRIES_COUNT** (defaults to 3): maximum amount of retries for 5xx errors. If server still responding 5xx, error will be thrown.
237
+
***API_REQUEST_TIMEOUT** (defaults to 15000): specifies the number of milliseconds before the request times out. If the request takes longer than timeout, the request will be aborted.
238
+
239
+
-`axiosReqWithRetryOnServerError` (use with `.call()` to pass context, implement it as a method of class with `logger` and `cfg` (value of configuration object for current action) values in a constructor) - function which makes axios request by specified request-config, making logging and error handling:
240
+
1. If 5xx error occurred, it will be retried maximum `API_RETRIES_COUNT` times, each retry will be delayed with `exponentialSleep` function.
241
+
2. If 4xx error occurred - error will be throw.
242
+
3. If action `cfg` has `doNotThrow404` set to true: 404 error won't be treated as error. <br>
243
+
Look on examples below.
244
+
-`getErrMsg` - forms error message from axios-response.
245
+
-`getRetryOptions` - return valid values for envs `API_RETRIES_COUNT` and `API_REQUEST_TIMEOUT`. If values are higher or lower the limit - they'll be overwritten by default values.
246
+
-`sleep` - return promise which resolves after N time.
247
+
-`exponentialDelay` - returns number of milliseconds depending to current retry. See [exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff) to explanation.
248
+
-`exponentialSleep` - return promise which resolves after N time. Where N is number of milliseconds from `exponentialDelay` execution.
249
+
250
+
Example for `axiosReqWithRetryOnServerError` function:
The built in logger uses Bunyan Logger as its base implementation. The available logger methods can be found [here](https://github.com/elasticio/component-commons-library/blob/master/src/logger/logger.ts#L19).
0 commit comments