donot_fail
v1.1.4
Published
library for retrying the code,asynchronously on failure
Downloads
9
Maintainers
Readme
Please Do not Fail !
Why use?
In Programming everything is not always predictable.So We need to put a shield over our code to overcome unintended errors.Simply put if request something from an external provider, Like creating payment gateway token,send an EMail / SMS via API.In these situations we have to determine what to do when these providers went down even for a fraction of second.Thats where you can use this package.
How to use?
Syntax:
tryAgain(RETRYABLE_FUNCTION,TIMES_WANT_TO_RETRY,TIME_INTERVAL_IN_SECONDS,FUNCTION_TO_EXECUTE_ON_SUCCESS,FUNCTION_TO_EXECUTE_ON_FAILURE,param1,param2,paramN)
Example
const donot_fail=require('donot_fail')
const codeThatMayFail=(name,apiKey)=>{
actionThatMayFail()
}
const secondsToRetry=1 //this will be doubled after each retry
donot_fail(codeThatMayFail,5,1,
(result) => {console.log("Result is " + result);},
(error) => {console.log("Error is " + error);},
"Alex",
"api_key_12345")