2017 © Pedro Peláez
 

library backoffv2

Backoff algorithms implemented in PHP

image

patinthehat/backoffv2

Backoff algorithms implemented in PHP

  • Thursday, February 16, 2017
  • by patinthehat
  • Repository
  • 1 Watchers
  • 1 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

## BackoffV2 Build Status

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

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., (*2)


Installation

Install BackoffV2 with Composer:, (*3)

composer require patinthehat/backoffv2, (*4)


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., (*5)


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

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

Backoff algorithms include:, (*7)

  • 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:, (*8)

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

Usage is simple:, (*9)

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., (*10)

The Versions

16/02 2017

dev-master

9999999-dev

Backoff algorithms implemented in PHP

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

by Patrick Organ

16/02 2017

v1.1.0

1.1.0.0

Backoff algorithms implemented in PHP

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

by Patrick Organ

15/02 2017

v1.0.2

1.0.2.0

Backoff algorithms implemented in PHP

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

by Patrick Organ

15/02 2017

v1.0.1

1.0.1.0

Backoff algorithms implemented in PHP

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

by Patrick Organ

15/02 2017

v1.0.0

1.0.0.0

Backoff algorithms implemented in PHP

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

by Patrick Organ