webclient/ext-retry

Retry extension for PSR-18 HTTP client

v1.0.1 2022-07-22 14:50 UTC

This package is not auto-updated.

Last update: 2024-11-23 01:41:35 UTC


README

Latest Stable Version Total Downloads License PHP

webclient/ext-retry

Retry extension for PSR-18 HTTP client.

Install

Install this package and your favorite psr-18 implementation.

composer require webclient/ext-retry:^1.0

Using

<?php

use Webclient\Extension\Retry\RetryClientDecorator;
use \Webclient\Extension\Retry\Timer\Timer;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestInterface;

/** 
 * @var ClientInterface $client Your PSR-18 HTTP Client
 * @var Timer $timer Timer implements
 * @var int $maxAttempts Max attempts
 */
$http = new RetryClientDecorator($client, $timer, $maxAttempts);

/** @var RequestInterface $request */
$response = $http->sendRequest($request);