Make an asynchronous funcion retryable
async_retryable(task, times)Asynchronous retryable function.
Other async control flow:
async_backoff(),
async_reflect(),
async_retry(),
async_sequence(),
async_try_each(),
async_until(),
async_whilst()
httpbin <- webfakes::new_app_process(webfakes::httpbin_app())
## Create a downloader that retries five times
http_get_5 <- async_retryable(http_get, times = 5)
ret <- synchronise(
http_get_5(httpbin$url("/get?q=1"))$
then(function(x) rawToChar(x$content))
)
cat(ret)
#> {
#> "args": {
#> "q": "1"
#> },
#> "headers": {
#> "Host": "127.0.0.1:42065",
#> "User-Agent": "R/4.6.1 R (4.6.1 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions",
#> "Accept": "*/*",
#> "Accept-Encoding": "deflate, gzip, br, zstd"
#> },
#> "origin": "127.0.0.1",
#> "path": "/get",
#> "url": "http://127.0.0.1:42065/get"
#> }