Create the request control object for spq_init()
Source: R/spq_control_request.R
spq_control_request.Rd
Create the request control object for spq_init()
Usage
spq_control_request(
user_agent = getOption("glitter.ua",
"glitter R package (https://github.com/lvaudor/glitter)"),
max_tries = getOption("glitter.max_tries", 3L),
max_seconds = getOption("glitter.max_seconds", 120L),
timeout = getOption("glitter.timeout", 1000L),
request_type = c("url", "body-form"),
rate = NULL,
realm = NULL
)
Arguments
- user_agent
a string indicating the user agent to send with the query.
- max_tries, max_seconds
Cap the maximal number of attemps with
max_tries
or the total elapsed time from the first request withmax_seconds
.- timeout
maximum number of seconds to wait (
httr2::req_timeout()
).- request_type
a string indicating how the query should be sent: in the URL (
url
, default, most common) or as a body form (body-form
).- rate
Maximum rate, i.e. maximum number of requests per second. Usually easiest expressed as a fraction,
number_of_requests / number_of_seconds
, e.g. 15 requests per minute is15 / 60
.- realm
An unique identifier that for throttle pool. If not supplied, defaults to the hostname of the request.
Value
A list to be used in spq_init()
's request_control
argument.
Examples
# Defaults
spq_control_request()
#> $user_agent
#> [1] "glitter R package (https://github.com/lvaudor/glitter)"
#>
#> $max_tries
#> [1] 3
#>
#> $max_seconds
#> [1] 120
#>
#> $timeout
#> [1] 1000
#>
#> $request_type
#> [1] "url"
#>
#> $rate
#> NULL
#>
#> $realm
#> NULL
#>
#> attr(,"class")
#> [1] "glitter_request_control"
# Tweaking values
spq_control_request(
user_agent = "Jane Doe https://example.com",
max_tries = 1L,
max_seconds = 10L,
timeout = 10L,
request_type = "url"
)
#> $user_agent
#> [1] "Jane Doe https://example.com"
#>
#> $max_tries
#> [1] 1
#>
#> $max_seconds
#> [1] 10
#>
#> $timeout
#> [1] 10
#>
#> $request_type
#> [1] "url"
#>
#> $rate
#> NULL
#>
#> $realm
#> NULL
#>
#> attr(,"class")
#> [1] "glitter_request_control"