# http-resilient-executor

> NodeJS http resilient executor

Latest version **1.0.0** (published 2024-02-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install http-resilient-executor
pnpm add http-resilient-executor
yarn add http-resilient-executor
bun add http-resilient-executor
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2024-02-21 |
| First published | 2024-02-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 66.8 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| Author | Byteverse |
| Maintainers | anokhi0895 |
| Keywords | axios, logger, cockatiel |

## Links

- npm: https://www.npmjs.com/package/http-resilient-executor
- Repository: https://github.com/anokhimg/common-nodejs-components
- Homepage: https://github.com/anokhimg/common-nodejs-components/packages/http-resilient-executor#readme
- Issues: https://github.com/anokhimg/common-nodejs-components/issues
- npm.io page: https://npm.io/package/http-resilient-executor

## Dependencies (3)

- [axios](https://npm.io/package/axios.md) ^0.24.0
- [cockatiel](https://npm.io/package/cockatiel.md) ^3.0.0-beta.1
- [commonjs-logger](https://npm.io/package/commonjs-logger.md) ^1.0.0

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2024-02-21

## README

# `http-resilient-executor`

Helper for creating retry policies , circuit breaker for functions and external requests

## Config

| Name                                        | Description                                                           |
| ------------------------------------------- | --------------------------------------------------------------------- |
| httpResilienceCBHalfOpenAfterMS             | Indicates the Time CircuitBreaker to be in half open state            |
| httpResilienceRetryCount                    | Retry count for requests                                              |
| httpResilienceCBConsecutiveThreshold        | Maximum attempts to open CircuitBreaker                               |

For logger configuration properties see the
[logger documentation](https://gitlab.byteprophecy.accenture.com/dataverse/common-nodejs-components/blob/develop/packages/logger/README.md)


## Usage

```typescript
// init ResilientExecutor instance (should use 1 instance per app)
import { ResilientExecutor } from 'http-resilient-executor';

const config = {
  /** logger configuration */
  logger: { logLevel: 'cli', logStyle: 'debug', appName: 'nodejs-commons',moduleName: 'ResilientExecutor' },

  /** After 10 seconds the CB will be half open state */
  httpResilienceCBHalfOpenAfterMS: 10 * 1000,

  /** After 5 consecutive failed requests, the CB will be open */
  httpResilienceCBConsecutiveThreshold: 5,

  /**  Retry count for failed requests */
  httpResilienceRetryCount: 3,
};

const resilientExec = new ResilientExecutor(config);

/** use resilientExecutor to wrap functions and api calls */
/** to wrap function */
await resilientExec.execute(testMock);

/** to wrap api */

await this.executor.execute(() =>
        axios.post(this.authUrl, params,
        {
          headers: { 'Content-Type': 'application/x-www-form-urlencoded'},
          auth: credentials,
        }),
      );

```

---
_Source: https://npm.io/package/http-resilient-executor · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
