File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 3
3
4
4
use \Curl \Curl ;
5
5
6
+ $ max_retries = 3 ;
7
+
6
8
$ 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 ;
9
11
});
10
12
$ curl ->get ('https://httpbin.org/status/503 ' );
11
13
Original file line number Diff line number Diff line change 3
3
4
4
use \Curl \MultiCurl ;
5
5
6
+ $ max_retries = 3 ;
7
+
6
8
$ 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 ;
9
11
});
10
12
$ multi_curl ->complete (function ($ instance ) {
11
13
echo 'call to " ' . $ instance ->url . '" completed. ' . "\n" ;
You can’t perform that action at this time.
0 commit comments