forked from igorw/retry
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
713 additions
and
342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
vendor | ||
/vendor/ | ||
/.*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
notifications: | ||
email: false | ||
|
||
sudo: false | ||
|
||
language: php | ||
|
||
php: | ||
- 5.5 | ||
- 5.6 | ||
- 7.0 | ||
|
||
install: | ||
- alias composer=composer\ -n && composer selfupdate | ||
- composer validate | ||
- composer --prefer-source install | ||
- composer --prefer-source require satooshi/php-coveralls | ||
|
||
script: | ||
- bin/test --coverage-clover=build/logs/clover.xml | ||
|
||
after_success: | ||
- vendor/bin/coveralls -v |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,50 @@ | ||
# retry | ||
Retry | ||
===== | ||
|
||
A tiny library for retrying failing operations. | ||
[![Latest version][Version image]][Releases] | ||
[![Build status][Build image]][Build] | ||
[![Test coverage][Coverage image]][Coverage] | ||
[![Code style][Style image]][Style] | ||
|
||
Since the network is reliable, things should always work. Am I right? For those cases when they don't, there is *retry*. | ||
Retry provides a function to retry failing operations. An operation is deemed to have failed if it throws an exception. | ||
|
||
```php | ||
<? | ||
use function igorw\retry; | ||
Requirements | ||
------------ | ||
|
||
// retry an operation up to 5 times | ||
$user = retry(5, function () use ($id) { | ||
return User::find($id); | ||
}); | ||
- [PHP 5.5](http://php.net/) | ||
- [Composer](https://getcomposer.org/) | ||
|
||
Usage | ||
----- | ||
|
||
The `retry` function has the following signature. | ||
|
||
``` | ||
retry(int $times, callable $operation); | ||
``` | ||
* `$times` specifies how many times the operation may be called. | ||
* `$operation` is a callback to be run up to the specified number of times. | ||
|
||
Note that in the [original library](https://github.com/igorw/retry), `$times` specified the number of *retries* and therefore the operation could run up to `n + 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 never run. | ||
|
||
### Example | ||
|
||
// here is why you want to start using HHVM | ||
$user = retry(5, () ==> User::find($id)); | ||
```php | ||
use function ScriptFUSION\Retry\retry; | ||
|
||
// this is probably a bad idea | ||
$user = retry(INF, () ==> { | ||
throw new RuntimeException('never gonna give you up'); | ||
// Try an operation up to 5 times. | ||
$response = retry(5, function () use ($url) { | ||
return HttpConnector::fetch($url); | ||
}); | ||
?> | ||
``` | ||
|
||
I know. You're welcome. | ||
|
||
[Releases]: https://github.com/ScriptFUSION/Retry/releases | ||
[Version image]: https://poser.pugx.org/scriptfusion/retry/v/stable "Latest version" | ||
[Build]: http://travis-ci.org/ScriptFUSION/Retry | ||
[Build image]: https://travis-ci.org/ScriptFUSION/Retry.svg "Build status" | ||
[Coverage]: https://coveralls.io/github/ScriptFUSION/Retry | ||
[Coverage image]: https://coveralls.io/repos/ScriptFUSION/Retry/badge.svg "Test coverage" | ||
[Style]: https://styleci.io/repos/62990558 | ||
[Style image]: https://styleci.io/repos/62990558/shield?style=flat "Code style" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
cd "$(dirname "$0")"/.. | ||
|
||
vendor/bin/phpunit -c test "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,29 @@ | ||
{ | ||
"name": "igorw/retry", | ||
"description": "A tiny library for retrying failing operations.", | ||
"keywords": ["failure"], | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Igor Wiedler", | ||
"email": "igor@wiedler.ch" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.4" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "~4.2" | ||
}, | ||
"autoload": { | ||
"files": ["src/retry.php"] | ||
"name": "scriptfusion/retry", | ||
"description": "Retries failing operations.", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Bilge", | ||
"email": "bilge@scriptfusion.com" | ||
}, | ||
"extra": { | ||
"branch-alias": { "dev-master": "1.0-dev" } | ||
{ | ||
"name": "Igor Wiedler", | ||
"email": "igor@wiedler.ch" | ||
} | ||
], | ||
"require": { | ||
"php": "^5.5|^7" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^4" | ||
}, | ||
"autoload": { | ||
"files": [ | ||
"src/retry.php" | ||
], | ||
"psr-4": { | ||
"ScriptFUSION\\Retry\\": "src" | ||
} | ||
} | ||
} |
Oops, something went wrong.