Skip to content

Commit

Permalink
docs: add documentation and types
Browse files Browse the repository at this point in the history
  • Loading branch information
metcoder95 committed Apr 25, 2024
1 parent 8ee7656 commit 917f5ae
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/docs/api/RetryHandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Extends: [`Dispatch.DispatchOptions`](Dispatcher.md#parameter-dispatchoptions).
- **methods** `string[]` (optional) - Array of HTTP methods to retry. Default: `['GET', 'PUT', 'HEAD', 'OPTIONS', 'DELETE']`
- **statusCodes** `number[]` (optional) - Array of HTTP status codes to retry. Default: `[429, 500, 502, 503, 504]`
- **errorCodes** `string[]` (optional) - Array of Error codes to retry. Default: `['ECONNRESET', 'ECONNREFUSED', 'ENOTFOUND', 'ENETDOWN','ENETUNREACH', 'EHOSTDOWN', 'UND_ERR_SOCKET']`
- **ifMatch** `boolean` (optional) - It enables the send of `if-match` pre-condition header if `etag` is present in the first response. Default: `true`

**`RetryContext`**

Expand Down
2 changes: 1 addition & 1 deletion test/types/retry-agent.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { RetryAgent, Agent } from '../..'
const dispatcher = new Agent()

expectAssignable<RetryAgent>(new RetryAgent(dispatcher))
expectAssignable<RetryAgent>(new RetryAgent(dispatcher, { maxRetries: 5 }))
expectAssignable<RetryAgent>(new RetryAgent(dispatcher, { maxRetries: 5, ifMatch: false }))

{
const retryAgent = new RetryAgent(dispatcher)
Expand Down
7 changes: 7 additions & 0 deletions types/retry-handler.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ declare namespace RetryHandler {
* @default [500, 502, 503, 504, 429],
*/
statusCodes?: number[];
/**
* Enables/disabled the usage of `If-Match` pre-condition header for retry requests.
* @type {boolean}
* @memberof RetryOptions
* @default true
*/
ifMatch?: boolean;
}

export interface RetryHandlers {
Expand Down

0 comments on commit 917f5ae

Please sign in to comment.