circuit-breaker-aopromise
Circuit-breaker aspect for aopromise aspect oriented programming toolkit to manage. It circuit-breaker-js as the underlying implementation, extending with timeout and fallback feature.
Quick start
You can use the aspect simply applying it to the wrapped method. You may pass configuration options to the aspect according to the documentation of circuit-breaker-js.
var aop = ;aop; // some remote service callvar remoteService = {};remoteServicegetData = // you may specify options ; remoteService ;
Fallback
If the circuit is open, circuit-breaker will fast-fail, meaning it will return a rejected promise without calling the wrapped method. You may pass a fallback method for open circuit if applicable.
var prices; // price cache // remote price apiremoteServicegetPrices = ; remoteService ;
Default options
You may want to set default options for every aspect added. You can do that by registering the aspect with the withDefaults converter.
var aop = ;var CircuitBreakerAspect = Aspect;aop; var remoteService = {};remoteServicegetData = // Options above are applied ;