$cb = new Aguimaraes\CircuitBreaker(
new Aguimaraes\Adapter\ACPu()
);
// number of errors necessary to open the circuit
$cb->setThreshold('my-service', 10);
// wait x seconds to check if service is back
$cb->setTimeout('my-service', 60);
$response = null;
if ($cb->isAvailable('my-service')) {
try {
$response = $service->makeCall();
$cb->reportSuccess('my-service');
} catch (ServiceException $e) {
$cb->reportFailure('my-service');
} catch (NonServiceRelatedException $e) {
// something went wrong and it was not the service fault
}
}
-
Notifications
You must be signed in to change notification settings - Fork 2
Implementation of the circuit breaker pattern
License
aguimaraes/circuit-breaker
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Implementation of the circuit breaker pattern
Topics
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published