Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/julekgwa/simplified-hystrixjs
Netflix's Hystrix latency and fault tolerance library, for Node.js
https://github.com/julekgwa/simplified-hystrixjs
hystrix hystrix-command nodejs npm-module
Last synced: 2 months ago
JSON representation
Netflix's Hystrix latency and fault tolerance library, for Node.js
- Host: GitHub
- URL: https://github.com/julekgwa/simplified-hystrixjs
- Owner: julekgwa
- License: mit
- Created: 2018-06-09T22:31:33.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-06T14:49:18.000Z (about 2 years ago)
- Last Synced: 2024-10-02T16:36:43.354Z (3 months ago)
- Topics: hystrix, hystrix-command, nodejs, npm-module
- Language: JavaScript
- Homepage:
- Size: 1.5 MB
- Stars: 8
- Watchers: 3
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/julekgwa/simplified-hystrixjs.svg?branch=master)](https://travis-ci.org/julekgwa/simplified-hystrixjs) [![npm version](https://badge.fury.io/js/simplified-hystrixjs.svg)](https://badge.fury.io/js/simplified-hystrixjs)
# simplified-hystrixjs
A simplified hystrixjs library for Nodejs based on [opossum](https://www.npmjs.com/package/opossum)
### Install
```
$ npm i simplified-hystrixjs -S
```### Usage
```Javascript
const { createHystrixCommands, createHystrixStream, getPrometheusStream } = require('simplified-hystrixjs');function hello(name) {
return new Promise(function(resolve, reject) {
setTimeout(function () {
resolve(`Hello, ${name}`)
}, 1000);
});
}const serviceCommand = createHystrixCommands(hello, { name : 'HelloService'});
app.get('/hello', async (req, res) => {
try {
const response = await serviceCommand.hello(req.query.name);
res.send(response)
} catch (e) {
console.log(e);
}
});
```### Methods
**createCommands(fn, service);**
**fn** - can be of type object, Array of functions or a function.
**service** - service object with the following properties
* *statisticalWindowNumberOfBuckets* - number of buckets within the statistical window
* *statisticalWindowLength* - length of the window to keep track of execution counts metrics (success, failure)
* *errorThreshold* - error percentage threshold to trip the circuit
* *timeout* for request
* *cbRequestVolume* - minimum number of requests in a rolling window
* *cbsleep* - how long the circuit breaker should stay opened.
* *name* - service name
* *isFailure* - emitted when the breaker action fails, called with the error
* *modifyError* - modifies the error message by adding circuit name. false by default.### Monitoring
Expose a monitoring endpoint for hystrix stream.
```Javascript
createHystrixStream(app, /*[endpoint]*/); // default /manage/hystrix.stream
```Prometheus stream.
```Javascript
getPrometheusStream()
```### Hystrix Dashboard
![monitorer](images/hystrix-dash.gif)
to run the dashboard, download [standalone-hystrix-dashboard](https://bintray.com/kennedyoliveira/maven/standalone-hystrix-dashboard)
̨
and run
```java
$ java -jar standalone-hystrix-dashboard-{VERSION}-all.jar
```
Access the dashboard in your browser: http://localhost:7979/hystrix-dashboard### Contributing
We gladly welcome pull requests and code contributions, take care to maintain the existing coding style.