1 | <?php |
||
19 | final class RetryPlugin implements Plugin |
||
20 | { |
||
21 | /** |
||
22 | * Number of retry before sending an exception. |
||
23 | * |
||
24 | * @var int |
||
25 | */ |
||
26 | private $retry; |
||
27 | |||
28 | /** |
||
29 | * @var callable |
||
30 | */ |
||
31 | private $delay; |
||
32 | |||
33 | /** |
||
34 | * @var callable |
||
35 | */ |
||
36 | private $decider; |
||
37 | |||
38 | /** |
||
39 | * Store the retry counter for each request. |
||
40 | * |
||
41 | * @var array |
||
42 | */ |
||
43 | private $retryStorage = []; |
||
44 | |||
45 | /** |
||
46 | * @param array $config { |
||
47 | * |
||
48 | * @var int $retries Number of retries to attempt if an exception occurs before letting the exception bubble up. |
||
49 | * @var callable $decider A callback that gets a request and an exception to decide after a failure whether the request should be retried. |
||
50 | * @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. |
||
51 | * } |
||
52 | */ |
||
53 | 7 | public function __construct(array $config = []) |
|
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | 4 | public function handleRequest(RequestInterface $request, callable $next, callable $first) |
|
127 | |||
128 | /** |
||
129 | * @param RequestInterface $request |
||
130 | * @param Exception $e |
||
131 | * @param int $retries The number of retries we made before. First time this get called it will be 0. |
||
132 | * |
||
133 | * @return int |
||
134 | */ |
||
135 | 4 | public static function defaultDelay(RequestInterface $request, Exception $e, $retries) |
|
139 | } |
||
140 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.