The goal of warrenr is to take persistently()
for a spin. This is based on
@richierocks's PR to purrr, where he proposes persistently()
. The goal is that this capability be merged into purrr.
You can install warrenr from github with:
# install.packages("devtools")
devtools::install_github("ijlyttle/warrenr")
Let's say you have an API call that does not work 100% of the time, due to vagaries of the network, etc.
result <- fragile_api_call(arg1 = "foo", ...)
If the call fails, you would like that the call be repeated. Hence the adverb persistently()
.
persistent_api_call <- warrenr::persistently(fragile_api_call)
This returns a new function that will run persistently:
result <- persistent_api_call(arg1 = "foo", ...)
There are arguments for max_attempts
(default: 5) and wait_seconds
(default: 0.1 s). Should the function throw an error, each subsequent call will wait twice the amount of time as it previously waited (plus some random fuzz).
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.