承接 patinthehat/backoffv2 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

patinthehat/backoffv2

Composer 安装命令:

composer require patinthehat/backoffv2

包简介

Backoff algorithms implemented in PHP

README 文档

README

BackoffV2 is a PHP 5.5+ library implementing various backoff algorithms, such as exponential backoff.

This library only returns a backoff delay amount based on the selected algorithms; implementation of the actual delay mechanism (such as sleep()) is left to the user.

Installation

Install BackoffV2 with Composer:

composer require patinthehat/backoffv2

Implementation

"Jitter" is implemented, if you choose to use it. Jitter is a small, variable amount of time that is added to the backoff amount.

Available Jitter algorithms (roughly based on this post) include:

  • NoJitter - No jitter
  • FullJitter - Standard jitter amount
  • EqualJitter - More consistent jitter amounts
  • DecorrelatedJitter - Higher jitter amounts

Backoff algorithms include:

  • ExponentialBackoff - exponentially increase the backoff amount
  • ConstantBackoff - use the same backoff amount, regardless of the attempt count.
  • LinearBackoff - linear increase of the backoff amount, i.e. 1, 2, 3, 4, ...

Usage

Using the Backoff class

BackoffV2 implements a main class, Backoff, that acts as a container and manager for the backoff and jitter algorithms you choose. The constructor signature for Backoff is:

public function __construct($maxBackoff, BackoffStrategyInterface $backoff, JitterStrategyInterface $jitter)

Usage is simple:

include 'vendor/autoload.php';
use BackoffV2\Backoff;
use BackoffV2\Backoff\ExponentialBackoff;
use BackoffV2\Jitter\FullJitter;

$b = new Backoff(15, new ExponentialBackoff, new FullJitter);

echo 'backoff = '.$b->getBackoff() . PHP_EOL;
echo 'backoff = '.$b->getBackoff() . PHP_EOL;
echo 'backoff = '.$b->getBackoff() . PHP_EOL;
echo 'backoff = '.$b->getBackoff() . PHP_EOL;
echo 'backoff = '.$b->getBackoff() . ' (attempt ' . $b->getAttempt().')' . PHP_EOL;
$b->reset();

License

BackoffV2 is available under the MIT License.

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-02-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固