Skip to content

Trooba based handler that provides more consistent too busy functionality based on hystrixjs and toobusy-js functionality

Notifications You must be signed in to change notification settings

trooba/trooba-toobusy-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

trooba-toobusy-handler

Greenkeeper badge

The module provides trooba too-busy handler. The handler is based on hystrix-too-busy module

codecov Build Status NPM Downloads Known Vulnerabilities

Install

$ npm install trooba-toobusy-handler -S

Usage

const toobusy = require('trooba-toobusy-handler');

toobusy.configure({
    latencyThreshold: 70,
    interval: 500,
    default: {
        circuitBreakerErrorThresholdPercentage: 50,
        circuitBreakerRequestVolumeThreshold: 20,
        circuitBreakerSleepWindowInMilliseconds: 5000
    }
});

require('trooba')
// optional: command resolver used by toobusy
.use(pipe => {
    pipe.on('request', request => {
        pipe.context.command =
            request.path === '/' ? 'homeCommand' : 'otherCommand';
    });
})
// add toobusy
.use(toobusy)
// add http transport
.use('trooba-http-transport', {
    protocol: 'http:',
    hostname: 'www.google.com'
})
.build('client:default')
.get({
    q: 'nike'
})
.set('some', 'header')
.end(function (err, response) {
    console.log(err, response && response.body)
});

About

Trooba based handler that provides more consistent too busy functionality based on hystrixjs and toobusy-js functionality

Resources

Stars

Watchers

Forks

Packages

No packages published