Skip to contents

Decide when retry() gives up. A condition is checked after each failed attempt.

Usage

stop_never()

stop_after_attempt(max_attempt_number = 1)

stop_after_delay(max_delay = 1)

stop_before_delay(max_delay = 1)

stop_any(...)

stop_all(...)

Arguments

max_attempt_number

Number of attempts to allow.

max_delay

Seconds since the first attempt.

...

Stop conditions to combine.

Value

A stop condition to pass to retry().

Details

  • stop_never() never stops.

  • stop_after_attempt() stops after a number of attempts.

  • stop_after_delay() stops once that many seconds have passed since the first attempt.

  • stop_before_delay() stops if sleeping again would reach that many seconds.

  • stop_any() stops when any of the given conditions is met.

  • stop_all() stops when all of the given conditions are met.

Examples

stop_after_attempt(3)
#> <garnish::stop_after_attempt>
#>  @ max_attempt_number: num 3
stop_any(stop_after_attempt(5), stop_after_delay(10))
#> <garnish::stop_any>
#>  @ stops:List of 2
#>  .. $ : <garnish::stop_after_attempt>
#>  ..  ..@ max_attempt_number: num 5
#>  .. $ : <garnish::stop_after_delay>
#>  ..  ..@ max_delay: num 10