ekomobile/retry
Composer 安装命令:
composer require ekomobile/retry
包简介
Retry with backoff
README 文档
README
This is a PHP port of https://github.com/cenkalti/backoff (thanks, @cenkalti), which is a port of the exponential backoff algorithm from Google's HTTP Client Library for Java.
Exponential backoff is an algorithm that uses feedback to multiplicatively decrease the rate of some process, in order to gradually find an acceptable rate. The retries exponentially increase and stop increasing when a certain threshold is met.
Examples
Simple
Retry with default exponential backoff.
(new Retry(function () { // workload ... }))();
Advanced
$operation = function () { // workload ... if ($somePermanentFailCondition) { throw new \Ekomobile\Retry\Exception\Permanent(new \Exception('Unretryable error')) } // ... throw new Exception('Retryable error') }; $backoff = new \Ekomobile\Retry\Backoff\WithMaxRetries(new \Ekomobile\Retry\Backoff\Exponential(), 5); $notify = function (\Throwable $e) { // $logger->log($e); }; $retry = new \Ekomobile\Retry\Retry($operation, $backoff, $notify); $retry();
统计信息
- 总下载量: 546
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-12-11