igorw / retry Goto Github PK
View Code? Open in Web Editor NEWA tiny library for retrying failing operations.
License: MIT License
A tiny library for retrying failing operations.
License: MIT License
Looks like everything is working great with retry, why not add a 0.1.0 or 1.0.0 tag?
So we can finally start using this in projects that have the default minimum stability (stable
) specified in Composer.
This is more a question than an issue. Do you think an optional parameter for timeout will be beneficial?
If found this code in a legacy project I am mantaining
/**
* Keep trying a number of times until it actually saves. This is for really important tasks.
*
* @param $entity
* @param int $iterations
* @return bool
*/
public function reallySave( $entity, $iterations = 5 ) {
for( $i = 0; $i < $iterations; $i++ ) {
if( $entity->save() ) {
return TRUE;
}
//sleep for 100 milliseconds between each try. Without the delay two back to back attempts are likely to fail.
usleep( 100 * 1000 );
}
return FALSE;
}
I don't know if this is a bad practice, but I think retry could replace this.
May I ask if there is a reason why you prefer using goto instead of function recursion?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.