1. Go to this page and download the library: Download love-oss/resiliency 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/ */
love-oss / resiliency example snippets
use Resiliency\MainCircuitBreaker;
use Resiliency\Systems\MainSystem;
use Resiliency\Storages\SimpleArray;
use Resiliency\Clients\SymfonyClient;
use Symfony\Component\HttpClient\HttpClient;
$client = new SymfonyClient(HttpClient::create());
$mainSystem = MainSystem::createFromArray([
'failures' => 2,
'timeout' => 100,
'stripped_timeout' => 200,
'threshold' => 10000,
], $client);
$storage = new SimpleArray();
// Any PSR-14 Event Dispatcher implementation.
$dispatcher = new Symfony\Component\EventDispatcher\EventDispatcher;
$circuitBreaker = new MainCircuitBreaker(
$mainSystem,
$storage,
$dispatcher
);
/**
* @var Service $service
*/
$fallbackResponse = function ($service) {
return '{}';
};
$circuitBreaker->call(
'https://api.domain.com',
$fallbackResponse,
[
'query' => [
'_token' => '123456789',
]
]
);
$monitor = new SimpleMonitor();
// Collect information while listening
// to some circuit breaker events...
function listener(Event $event) {
$monitor->add($event);
};
// Retrieve a complete report for analysis or storage
$report = $monitor->getReport();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.