You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow a callable parameter to decide if require is going to be retrie… (#79)
* Allow a callable parameter to decide if require is going to be retried or not.
Also allow retry backoff
* Applied changes from StyleCI
* Some fixes
* Applied changes from StyleCI
* Updated changelog
* Stuff
Copy file name to clipboardExpand all lines: src/Plugin/RetryPlugin.php
+39-1Lines changed: 39 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,16 @@ final class RetryPlugin implements Plugin
24
24
*/
25
25
private$retry;
26
26
27
+
/**
28
+
* @var callable
29
+
*/
30
+
private$delay;
31
+
32
+
/**
33
+
* @var callable
34
+
*/
35
+
private$decider;
36
+
27
37
/**
28
38
* Store the retry counter for each request.
29
39
*
@@ -35,18 +45,28 @@ final class RetryPlugin implements Plugin
35
45
* @param array $config {
36
46
*
37
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 milliseconds we should wait before trying again.
38
50
* }
39
51
*/
40
52
publicfunction__construct(array$config = [])
41
53
{
42
54
$resolver = newOptionsResolver();
43
55
$resolver->setDefaults([
44
56
'retries' => 1,
57
+
'decider' => function (RequestInterface$request, Exception$e) {
0 commit comments