trooba-hystrix-handler

1.0.6 • Public • Published

trooba-hystrix-handler

Greenkeeper badge

Trooba handler that provides Hystrix functionality to trooba based service pipelines. For more details on this topic, please read these blog posts Part 1 and Part 2.

codecov Build Status NPM Downloads Known Vulnerabilities

Install

npm install trooba-hystrix-handler -S

Usage

The component collects services metrics and publishes it to process event stream under the topic 'trooba:hystrix:data'.

Pipeline configuration

const Trooba = require('trooba');
// config is used to configure transport and hystrix handler
 
const pipe = Trooba
// set config parameters
.use(require('trooba-hystrix-handler'), {
    timeout: 2000,  // optional
    circuitBreakerErrorThresholdPercentage: 50, // optional
    circuitBreakerForceClosed: false, // optional
    circuitBreakerForceOpened: false, // optional
    circuitBreakerRequestVolumeThreshold: 20, // optional
    circuitBreakerSleepWindowInMilliseconds: 5000, // optional
    requestVolumeRejectionThreshold: 0, // optional
    statisticalWindowNumberOfBuckets: 10, // optional
    statisticalWindowLength: 10000, // optional
    percentileWindowNumberOfBuckets: 6, // optional
    percentileWindowLength: 60000 // optional
})
// add http transport
.use(require('trooba-http-transport'), {
    hostname: 'localhost',
    port: 8000
})
.build({
    fallback: (err, request) => {  // optional
        console.log(request); // will print {foo:'bar'}
        return Promise.resolve('fallback');
    }
});
 
pipe.create({
    command: 'my-service-command', // required
})
.request({
    foo: 'bar'
}, (err, response) => console.log(err, response));

Viewing metrics using Hystrix dashboard

In case an application and hystrix-dashboard are packaged together, one can expose hystrix.stream as one of the http commands.

const express = require('express');
const app = express();
const dashboard = require('hystrix-dashboard');
 
app.use(dashboard({
    // configurable hystrix metrics topic that trooba hystrix handler uses to publish data
    topic: 'trooba:hystrix:data'
}));
 
app.listen(8000); //  http://localhost:8080/hystrix.stream

Package Sidebar

Install

npm i trooba-hystrix-handler

Weekly Downloads

3

Version

1.0.6

License

MIT

Last publish

Collaborators

  • kprakasam
  • dimichgh