2017 © Pedro Peláez
 

library transient-fault-handler

Retry tasks that fail due to transient faults

image

graze/transient-fault-handler

Retry tasks that fail due to transient faults

  • Tuesday, April 18, 2017
  • by graze
  • Repository
  • 12 Watchers
  • 3 Stars
  • 2,482 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 24 % Grown

The README.md

Transient Fault Handler

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads, (*1)

Retries tasks that fail due to transient errors. Well suited to network requests but can retry any callable., (*2)

Install

Via Composer, (*3)

``` bash composer require graze/transient-fault-handler, (*4)


## Usage The transient fault handler takes two detection strategies and a retry strategy. The builder can be used to quickly create a handler. ``` php $task = function () { // Task that is prone to transient errors }; $builder = new TransientFaultHandlerBuilder(); $transientFaultHandler = $builder->build(); $result = $transientFaultHandler->execute($task);

Detection Strategy

When a task is tried, it will either return some value or throw an exception., (*5)

The detection strategies will decide if that value/exception indicates a transient error or not., (*6)

If it does, then the fault handler will be told to retry the task. if it does not, then the value/exception either indicates a success or a non-transient error that retrying wouldn't solve., (*7)

In these cases, the value is returned to the caller or the exception is rethrown., (*8)

  • FalseyReturnValueDetectionStrategy: treats return values that evaluate to false as transient.
  • StaticDetectionStrategy: returns a static value set when constructing the strategy, regardless of the return value or exception.

Retry Strategy

If the detection strategy decides that the task should be retried, the retry strategy will decide how long to wait before doing so (the backoff period), and optionally impose a maximum number of retries on the task., (*9)

  • ExponentialBackoffStrategy: the backoff period is chosen randomly between zero and an exponentially increasing maximum.

Builder

The builder makes it easier to create a fault handler by automatically injecting dependencies. The default strategies that the builder uses can be overridden by using the setters., (*10)

``` php, (*11)

$builder = new TransientFaultHandlerBuilder(); $transientFaultHandler = $builder ->setExceptionDetectionStrategy(new StaticDetectionStrategy()) ->setReturnValueDetectionStrategy(new FalseyReturnValueDetectionStrategy()) ->setRetryStrategy(new ExponentialBackoffStrategy()) ->setLogger(new Logger()) ->build();, (*12)


## Change log Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. ## Testing ``` bash make test

Contributing

Please see CONTRIBUTING for details., (*13)

Security

If you discover any security related issues, please email security@graze.com instead of using the issue tracker., (*14)

Credits

License

The MIT License (MIT). Please see License File for more information., (*15)

The Versions

18/04 2017

dev-master

9999999-dev https://github.com/graze/transient-fault-handler

Retry tasks that fail due to transient faults

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jake Wright

retry networking graze transient fault

15/03 2017

v0.3.0

0.3.0.0 https://github.com/graze/transient-fault-handler

Retry tasks that fail due to transient faults

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jake Wright

retry networking graze transient fault

14/03 2017

v0.2.0

0.2.0.0 https://github.com/graze/transient-fault-handler

Retry tasks that fail due to transient faults

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jake Wright

retry networking graze transient fault

02/03 2017

dev-factory

dev-factory https://github.com/graze/transient-fault-handler

Retry tasks that fail due to transient faults

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jake Wright

retry networking graze transient fault

02/03 2017

v0.1.0

0.1.0.0 https://github.com/graze/transient-fault-handler

Retry tasks that fail due to transient faults

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jake Wright

retry networking graze transient fault