-
Notifications
You must be signed in to change notification settings - Fork 43
Circuit Breaker Handler
thiagobustamante edited this page May 22, 2017
·
2 revisions
A CircuitBreaker Handler middleware is a function called when circuitbreaker events occurs. The events cal be a state change('open'
or 'close'
) or a request rejection due to a circuit 'open' state.
It receives the following parameters:
- apiPath: The path being called to target API.
- event: The event that originated the call. Can be
'open'
,'close'
or'rejected'
.
Each middleware must be defined on its own .js file.
Example:
/**
* @param apiPath The path being called to target API.
* @param event The event that originated the call. Can be 'open', 'close' or 'rejected'.
*/
module.exports = function (apiPath, event) {
sendEmail('Event received: '+ event, apiPath);
};
You can configure a circuitbreaker handler middleware through:
- Admin Rest API:
POST /midleware/circuitbreaker
- SDK:
sdk.middleware.addCircuitBreaker(name, fileName);
- CLI:
treeGatewayConfig middleware circuitbreaker -a <name> ./filename.js