# adaptive-accrual-failure-detector

> Failure detection for processes, connections and distributed systems

Latest version **1.0.0** (published 2021-06-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install adaptive-accrual-failure-detector
pnpm add adaptive-accrual-failure-detector
yarn add adaptive-accrual-failure-detector
bun add adaptive-accrual-failure-detector
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2021-06-19 |
| First published | 2018-11-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 22.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | aholstenson |
| Keywords | failure detector, distributed, networking |

## Links

- npm: https://www.npmjs.com/package/adaptive-accrual-failure-detector
- Repository: https://github.com/aholstenson/adaptive-accrual-failure-detector
- Homepage: https://github.com/aholstenson/adaptive-accrual-failure-detector#readme
- Issues: https://github.com/aholstenson/adaptive-accrual-failure-detector/issues
- npm.io page: https://npm.io/package/adaptive-accrual-failure-detector

## Recent versions

- 1.0.0 (latest) — 2021-06-19
- 0.2.0 — 2019-04-22
- 0.1.1 — 2018-11-26
- 0.1.0 — 2018-11-26

## README

# adaptive-accrual-failure-detector

[![npm version](https://badge.fury.io/js/adaptive-accrual-failure-detector.svg)](https://badge.fury.io/js/adaptive-accrual-failure-detector)

Failure detection for processes, connections and distributed systems. This is
an implementation for JavaScript and TypeScript of a failure detector that uses
an adaptive accrual algorithm. The theory of this detector is taken from the paper
[A New Adaptive Accrual Failure Detector for Dependable Distributed System](https://www.informatik.uni-augsburg.de/lehrstuehle/sik/publikationen/papers/2007_sac-dads_sat/paper.pdf)
authored by Benjamin Satzger, Andreas Pietzowski, Wolfang Trumler and 
Theo Ungerer.

This detector is useful for detecting things such as network failures between
two nodes.

## Usage

The failure detector is based on incoming heartbeats and has a few options that
can be used when creating the detector:

*
  `sampleSize` - number of samples kept and used when calculating probability
  of a failure. A higher number of samples means the probability calculation is
  more stable but uses more memory. Default is `1000`.
*
  `scalingFactor` - factor used to scale failure probabilities, used to reduce
  overestimation of failure. Default is `0.9`.
*
  `failureThreshold` - the probability needed to to detect something as a
  failure. If the probability of failure is above this the thing being 
  monitored is considered failed. Default is `0.5`.

```javascript
// Using ES Module environment
import { FailureDetector } from 'adaptive-accrual-failure-detector';

const detector = new FailureDetector({
  failureThreshold: 0.6
});
```

When you receive a heartbeat you should call `registerHeartbeat` on the detector:

```javascript
detector.registerHeartbeat();
```

To calculate if a failure has occurred you can call `checkFailure()` or
`calculateFailureProbability()`:

```javascript
// Check failure, will return true if failed
const isFailed = detector.checkFailure();

// Calculate the probability of failure between 0 and 1
const failureProbability = detector.calculateFailureProbability();
```

---
_Source: https://npm.io/package/adaptive-accrual-failure-detector · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
