PHP code example of eshta / resilient-task
1. Go to this page and download the library: Download eshta/resilient-task 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/ */
eshta / resilient-task example snippets
use GuzzleHttp\Exception\ConnectException;
$task = function() {
try {
$response = $client->request('GET', 'https://github.com/_abc_123_404');
return $response;
} catch (ConnectException $e) {
echo Psr7\str($e->getRequest());
}
};
$runner = new ResilientTaskRunner(10, 16, 0.5);
$response = $runner->run($task);
if (is_null($response)) {
throw new MyFavouriteException('Service call failed!');
}