Skip to content

Commit 07a2445

Browse files
committed
Added initial delay constructor parameter to ExponentialSleepFetchExceptionHandler.
1 parent 54d9a3d commit 07a2445

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"php": "^5.5|^7",
1313
"scriptfusion/static-class": "^1",
1414
"scriptfusion/retry": "^1.1",
15-
"scriptfusion/retry-exception-handlers": "^1",
15+
"scriptfusion/retry-exception-handlers": "^1.1",
1616
"psr/container": "^1",
1717
"psr/cache": "^1"
1818
},

src/Connector/FetchExceptionHandler/ExponentialSleepFetchExceptionHandler.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,24 @@
88
*/
99
class ExponentialSleepFetchExceptionHandler implements FetchExceptionHandler
1010
{
11+
private $initialDelay;
12+
1113
private $handler;
1214

15+
/**
16+
* Initializes this instance with the specified initial delay. The initial delay will be used when the first
17+
* exception is handled; subsequent exceptions will cause longer delays.
18+
*
19+
* @param int $initialDelay Initial delay.
20+
*/
21+
public function __construct($initialDelay = ExponentialBackoffExceptionHandler::DEFAULT_COEFFICIENT)
22+
{
23+
$this->initialDelay = $initialDelay | 0;
24+
}
25+
1326
public function initialize()
1427
{
15-
$this->handler = new ExponentialBackoffExceptionHandler;
28+
$this->handler = new ExponentialBackoffExceptionHandler($this->initialDelay);
1629
}
1730

1831
public function __invoke(\Exception $exception)

0 commit comments

Comments
 (0)