Retrying is off by default: the package default is attempts = 1.
Usage
zu_retry(
attempts = 3L,
backoff = c("exponential", "constant"),
base = 1,
max_delay = 60,
jitter = TRUE,
retry_after = TRUE,
max_retry_after = 60,
attempt_timeout = NULL,
on = NULL
)Arguments
- attempts
Total attempts including the first, so
attempts = 1means no retrying andattempts = 3means at most two retries.- backoff
"exponential"or"constant".- base
Seconds for the first backoff interval.
- max_delay
Ceiling for a single computed backoff, in seconds.
- jitter
Randomise each delay over
[0, delay]("full jitter"). On by default: synchronised retries from many R sessions are a real thundering-herd source (§33.3).- retry_after
Honour a
Retry-Afterresponse header.- max_retry_after
Clamp for
Retry-After, in seconds. A hostile or misconfigured server must not be able to pin an R session for hours.- attempt_timeout
Optional per-attempt bound in seconds. The
totaltimeout still bounds the whole call (§24.3); this bounds one try.- on
Extra HTTP statuses to treat as retryable, beyond §33.2's 408, 429, 500, 502, 503 and 504: whole numbers from 100 to 599.
Value
A zu_retry_policy, for zu_client(retry = ) or
zu_req_retry().
Details
A request with a streaming callback is not retried once the callback has
been handed any bytes: what it received, and did with them, cannot be taken
back, so a retry would give it a second body after the first. A retryable
failure that delivered nothing, such as a 503 with an empty body, is still
retried.
See also
zu_req_retry() for per-request opt-in, including the
replay-safety override that a POST needs.
Examples
zu_retry(attempts = 3)
#> <zu_retry_policy>
#> attempts: 3 (up to 2 retries)
#> backoff: exponential, base 1s, max 60s, full jitter
#> Retry-After honoured, clamped to 60s
zu_client(retry = zu_retry(attempts = 5, max_delay = 10))
#> <zu_client>
#> timeout: 30 (default)
#> redirects: 10 (default)
#> verify: TRUE (default)
#> max_body: 16777216 (default)
#> check: TRUE (default)
#> decode: TRUE (default)
#> retry: 5 attempts, exponential backoff, honours Retry-After
#> http2: auto (default)