Skip to contents

Sets how long the next dispatch to host should wait: from a 429 or 503's Retry-After when one was sent, or a default pause (5 seconds, BIOHTTP_RATELIMIT_DEFAULT_PAUSE to override) otherwise. A call only extends an existing pause, never shortens one, so of several retryable responses recorded from one batch, the longest asked-for wait wins.

Usage

ratelimit_record(host, retry_after = NULL, now = as.numeric(Sys.time()))

Arguments

host

A hostname, as returned by parsing a request URL.

retry_after

Seconds to wait, usually from httr2::resp_retry_after(). NULL or NA falls back to the default pause.

now

The current time in seconds since the epoch. Exposed so a test can drive the clock rather than sleep.

Value

The host's new pause_until, invisibly.

Examples

ratelimit_reset()
ratelimit_record("rest.ensembl.org", retry_after = 5)
ratelimit_reset()