Methods
retry
ΒΆ
retry(times:
Int
=60, sleep:
Any
=1, logger:
Fun
=
(a function)
, success_predicate:
Any
=
(a function)
, catch_exceptions:
Bool
=true, title:
Any
=<retry>, progress_cb:
Fun
=
(a function)
, success_cb:
Fun
=
(a function)
, fail_cb:
Any
=null, body:
Fun
=
(a function)
)
Retry. Executes given "body" "times" times. Throws RetryFail if all calls fail and fail_cb is not provided.
Source:
stdlib.ngs:4131
times
Limit of times to run "body"
sleep
Either sleep in seconds between tries or Iter that returns successive sleep times in seconds
logger
Function to use to log attempts, caught body exceptions and sleep times. Defaults to stdlib's debug.
success_predicate
CANDIDATE FOR REMOVAL. Run against body results to. Says whether the attempt succeeded. Defaults to Bool.
catch_exceptions
Catch exceptions that might occur in body and treat them as if body returned failure.
title
Prefix strings sent to logger with this string. Defaults to "<retry>".
progress_cb
Called before each attempt with (1) current attempt number and (2) limit of attempts ("times"). Defaults to do nothing.
success_cb
Called when body succeeds with the result that comes from body. Defaults to identity function.
fail_cb
If passed, called if all attempts fail. Defaults to null.
Returns
Any. Result of success_cb or result of fail_cb.
Example
page = retry(times=10, sleep=ExpBackIter(), body={ `curl "http://flaky-site.com"` })