1 | <?php |
||
18 | final class RetryPlugin implements Plugin |
||
19 | { |
||
20 | /** |
||
21 | * Number of retry before sending an exception. |
||
22 | * |
||
23 | * @var int |
||
24 | */ |
||
25 | private $retry; |
||
26 | |||
27 | /** |
||
28 | * @var callable |
||
29 | */ |
||
30 | private $delay; |
||
31 | |||
32 | /** |
||
33 | * @var callable |
||
34 | */ |
||
35 | private $decider; |
||
36 | |||
37 | /** |
||
38 | * Store the retry counter for each request. |
||
39 | * |
||
40 | * @var array |
||
41 | */ |
||
42 | private $retryStorage = []; |
||
43 | |||
44 | /** |
||
45 | * @param array $config { |
||
46 | * |
||
47 | * @var int $retries Number of retries to attempt if an exception occurs before letting the exception bubble up. |
||
48 | * @var callable $decider A callback that gets a request and an exception to decide after a failure whether the request should be retried. |
||
49 | * @var callable $delay A callback that gets a request, an exception and the number of retries and returns how many microseconds we should wait before trying again. |
||
50 | * } |
||
51 | */ |
||
52 | 7 | public function __construct(array $config = []) |
|
71 | |||
72 | /** |
||
73 | * {@inheritdoc} |
||
74 | */ |
||
75 | 4 | public function handleRequest(RequestInterface $request, callable $next, callable $first) |
|
110 | |||
111 | /** |
||
112 | * @param RequestInterface $request |
||
113 | * @param Exception $e |
||
114 | * @param int $retries The number of retries we made before. First time this get called it will be 0. |
||
115 | * |
||
116 | * @return int |
||
117 | */ |
||
118 | 4 | public static function defaultDelay(RequestInterface $request, Exception $e, $retries) |
|
122 | } |
||
123 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.