2017 © Pedro Peláez
 

library retry

Retries failing operations.

image

scriptfusion/retry

Retries failing operations.

  • Thursday, April 19, 2018
  • by Bilge
  • Repository
  • 2 Watchers
  • 4 Stars
  • 23,496 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 28 Forks
  • 0 Open issues
  • 8 Versions
  • 10 % Grown

The README.md

Retry

Latest version Total downloads Build status Test coverage ![Code style][Style image], (*1)

Retry provides a function to retry failing operations with optional Fiber support. An operation is deemed to have failed if it throws an exception. This library is a rewrite of Igor Wiedler's retry but aims to remain faithful to the spirit of the original., (*2)

Requirements

Usage

The retry function retries an operation up to the specified number of times with an optional exception handler., (*3)

If an exception handler is specified, it is called immediately before retrying the operation. If the handler returns false, the operation is not retried., (*4)

retry(int $times, callable $operation, callable $onError = null);
  • $times—Maximum number of times the operation may run.
  • $operation—Operation to run up to the specified number of times.
  • $onError—Optional. Exception handler that receives the thrown exception as its first argument.

Note in the original library, $times specifies the number of retries and therefore the operation could run up to $times + 1 times. In this version, $times specifies exactly the number of times the operation may run such that if zero (0) is specified it will not run., (*5)

Example

The following code fragment attempts to fetch data from a URL over HTTP up to five times., (*6)

use function ScriptFUSION\Retry\retry;

$response = retry(5, function () use ($url) {
    return HttpConnector::fetch($url);
});

The Versions

19/04 2018

dev-master

9999999-dev

Retries failing operations.

  Sources   Download

MIT

The Requires

  • php ^7

 

The Development Requires

by Avatar Bilge

19/04 2018

2.0.0

2.0.0.0

Retries failing operations.

  Sources   Download

MIT

The Requires

  • php ^7

 

The Development Requires

by Avatar Bilge

11/12 2016

1.1.1

1.1.1.0

Retries failing operations.

  Sources   Download

MIT

The Requires

  • php ^5.5|^7

 

The Development Requires

by Avatar Bilge

08/12 2016

1.1.0

1.1.0.0

Retries failing operations.

  Sources   Download

MIT

The Requires

  • php ^5.5|^7

 

The Development Requires

by Avatar Bilge

18/07 2016

1.0.0

1.0.0.0

Retries failing operations.

  Sources   Download

MIT

The Requires

  • php ^5.5|^7

 

The Development Requires

by Avatar Bilge

20/09 2014

dev-on-error

dev-on-error

A tiny library for retrying failing operations.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

failure

20/09 2014

dev-result-structure

dev-result-structure

A tiny library for retrying failing operations.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

failure

20/09 2014

dev-collect-exceptions

dev-collect-exceptions

A tiny library for retrying failing operations.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

failure