Skip to contents

A no-op when the host has no pause recorded, or the recorded one has already elapsed. sleep is injectable so a test can assert the duration asked for without actually waiting for it.

Usage

ratelimit_wait(host, now = as.numeric(Sys.time()), sleep = Sys.sleep)

Arguments

host

A hostname.

now

The current time in seconds since the epoch.

sleep

The sleep function to call with the remaining seconds. Defaults to Sys.sleep().

Value

The number of seconds waited (0 when there was nothing to wait for), invisibly.

Examples

ratelimit_reset()
ratelimit_wait("rest.ensembl.org")