Skip to contents

Configures bounded retry with exponential backoff for a request-policy. Pass the result as request_policy(retry = ). Only TRANSIENT failures retry: the retryable HTTP statuses set, plus transient transport errors when retry_on_failure = TRUE. Deterministic failures (SSRF, malformed input, resource-ceiling aborts) are never retried because they surface outside the single-hop req_perform() that retry wraps.

Usage

request_retry(
  max_tries = 3L,
  statuses = c(429L, 500L, 502L, 503L, 504L),
  backoff_min = 1,
  backoff_max = 30,
  retry_on_failure = FALSE
)

Arguments

max_tries

Total attempts per hop (>= 1). 1 means no retry.

statuses

Integer vector of retryable HTTP statuses. Defaults to the transient set 429, 500, 502, 503, 504.

backoff_min, backoff_max

Lower/upper bounds (seconds) for the exponential backoff between attempts. The delay for attempt i is backoff_min * 2^(i - 1), clamped to backoff_max. A Retry-After header is honored but likewise bounded by backoff_max, so no unbounded sleep.

retry_on_failure

When TRUE, transient transport errors (curl failures) are also retried. Defaults to FALSE (status-driven retry only).

Value

A sitemapr_request_retry object for request_policy(retry = ).

Examples

# Up to 4 attempts per hop, retrying the transient status set.
request_policy(retry = request_retry(max_tries = 4L))
#> $prepare
#> NULL
#> 
#> $headers
#> NULL
#> 
#> $auth
#> NULL
#> 
#> $proxy
#> NULL
#> 
#> $tls
#> NULL
#> 
#> $retry
#> $max_tries
#> [1] 4
#> 
#> $statuses
#> [1] 429 500 502 503 504
#> 
#> $backoff_min
#> [1] 1
#> 
#> $backoff_max
#> [1] 30
#> 
#> $retry_on_failure
#> [1] FALSE
#> 
#> attr(,"class")
#> [1] "sitemapr_request_retry"
#> 
#> $throttle
#> NULL
#> 
#> $max_active
#> NULL
#> 
#> attr(,"class")
#> [1] "sitemapr_request_policy"