PHP code example of solution10 / circuitbreaker
1. Go to this page and download the library: Download solution10/circuitbreaker library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
solution10 / circuitbreaker example snippets
$persistence = new \Doctrine\Common\Cache\ArrayCache();
$breaker = new \Solution10\CircuitBreaker\CircuitBreaker('my_backend_service', $persistence);
if ($breaker->isClosed()) {
$response = doSomething();
if ($response) {
$breaker->success();
} else {
$breaker->failure();
}
} else {
gracefullyDegrade();
}