Skip to content

Commit 74bd543

Browse files
committed
New notes
1 parent 4c2b43f commit 74bd543

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ Notes:
1414
* This is a fork. You can find the original project [here](https://github.com/stechstudio/backoff).
1515
* Now the codebase super strict, and it's covered with tests as much as possible. The original author is great, but the code was smelly :) It's sooo easy, and it took just one my evening... ;)
1616
* I don't like wording "backoff" in the code. Yeah, it's fun but... I believe "retry" is more obvious. Sorry :)
17-
* There is nothing wrong to use import instead of global namespace for function.
18-
* At least my project has [aliases](./src/aliases.php) for backward compatibility with the original. ;)
17+
* There is nothing wrong to use import instead of global namespace for function. Don't use old-school practices.
18+
* Static variables with default values are deprecated and disabled. See dump of thoughts below.
19+
* New methods `setJitterPercent|getJitterPercent`, `setJitterMinCap|getJitterMinCap` to have fine-tuning.
20+
* My project has [aliases](./src/aliases.php) for backward compatibility with the original. ;)
1921

2022

2123
## Installation
@@ -231,7 +233,7 @@ You can enable jitter by passing `true` in as the fifth argument to the `retry`
231233

232234
By default, we use the "FullJitter" approach outlined in the above article, where a random number between 0 and the sleep time provided by your selected strategy is used.
233235

234-
But you can change the maximum time for Jitter with method `setJitterPercent(). By default it's 100.
236+
But you can change the maximum time for Jitter with method `setJitterPercent(). It's 100 by default. Also you can set min value for jitter with `setJitterMinCap` (it's `0` by default).
235237

236238
## Custom retry decider
237239

@@ -259,7 +261,7 @@ use JBZoo\Retry\Retry;
259261

260262
$retry = new Retry();
261263
$retry->setErrorHandler(function($exception, $attempt, $maxAttempts) {
262-
Log::error("On run $attempt we hit a problem: " . $exception->getMessage());
264+
Log::error("On run {$attempt}/{$maxAttempts} we hit a problem: {$exception->getMessage()}");
263265
});
264266
```
265267

0 commit comments

Comments
 (0)