Description Arguments Value Usage Details Examples
Designed for accessing network resources that are unreliable, ntry will call a function up to n times, returning its result or fail.
fn |
A single argument function |
n |
The number of attempts to call the function |
The result of calling fn
ntry(fn, n) %::% Function : numeric : .
ntry(fn, n)
Imagine a function that attempts to access a network resource, like a web service or database. Sometimes there will be network timeouts that you want to recover from, without having to change the application logic. This function allows you to do that, while specifying a maximum retry limit so as not to block the function forever.
This higher-order function will call the specified function up to n times, returning on the first successful call. The function fn is a closure that takes a single argument representing the attempt number.
If calling the function fails n times, then ntry will fail with an error.
1 2 3 4 5 6 7 8 9 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.