all files / src/ request.js

100% Statements 5/5
75% Branches 3/4
100% Functions 0/0
100% Lines 5/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14   195× 195×                
const request = require('superagent');
const CommandsFactory = require('hystrixjs').commandFactory;
 
module.exports = config => {
    const circuitBreakerConfig = config.circuitBreaker;
    return CommandsFactory.getOrCreate(circuitBreakerConfig.service || 'defaultService')
        .circuitBreakerForceOpened(circuitBreakerConfig.circuitOpenByDefault || false)
        //.circuitBreakerErrorThresholdPercentage(circuitBreakerConfig.errorThreshold || 10)
        //.circuitBreakerSleepWindowInMilliseconds(circuitBreakerConfig.sleepTime || 60000)
        //.circuitBreakerRequestVolumeThreshold(circuitBreakerConfig.requestVolumeThreshold || 10)
        .timeout(3000)
        .run(request.get)
        .build();
};