Skip to content

Commit 50d4b27

Browse files
committed
Use configurable max retries
1 parent 63a7a30 commit 50d4b27

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

examples/get_with_callable_retry.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33

44
use \Curl\Curl;
55

6+
$max_retries = 3;
7+
68
$curl = new Curl();
7-
$curl->setRetry(function ($instance) {
8-
return $instance->retries < 3;
9+
$curl->setRetry(function ($instance) use ($max_retries) {
10+
return $instance->retries < $max_retries;
911
});
1012
$curl->get('https://httpbin.org/status/503');
1113

examples/multi_curl_get_with_callable_retry.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33

44
use \Curl\MultiCurl;
55

6+
$max_retries = 3;
7+
68
$multi_curl = new MultiCurl();
7-
$multi_curl->setRetry(function ($instance) {
8-
return $instance->retries < 3;
9+
$multi_curl->setRetry(function ($instance) use ($max_retries) {
10+
return $instance->retries < $max_retries;
911
});
1012
$multi_curl->complete(function ($instance) {
1113
echo 'call to "' . $instance->url . '" completed.' . "\n";

0 commit comments

Comments
 (0)