The trackFailure method updates the metrics when failure occurs. The metrics will be used whenClosed and whenHalfOpen methods.
The trackSuccess method updates the metrics when success occurs.
The whenClosed method should use currentMetrics and if needed currentDate to transition to open state or stay in closed state.
The whenHalfOpened method should use currentMetrics and if needed currentDate to transition to open state, closed state or stay in half open state.
The
ICircuitBreakerPolicycontract defines the circuite breaker algorithm. Note all the methods here are pure functions, meaning they should return copies and not mutate input data.IMPORT_PATH:
"@daiso-tech/core/circuit-breaker/contracts"