The batched counterpart to get_text(), for a source that ships several
flat files rather than one. Each body comes back verbatim as a string in
data, so the envelope shape matches the single call and a caller does not
branch on which wrapper it used.
Usage
get_text_many(
base_url,
path = NULL,
queries = list(),
source = "API",
timeout = 30,
max_tries = 3,
headers = NULL,
throttle = NULL,
max_active = 6,
progress = FALSE,
secret_query = NULL,
ttl = NULL
)Arguments
- base_url
The service's base URL.
- path
A path appended to
base_url. Length 1 to use the same path for every request, or one per entry inqueries.- queries
A list of named lists, one per request. Blank values are dropped from each.
- source
A friendly label for the service, used in the user-facing message. For example
"MyGene".- timeout
Seconds before a request is abandoned.
- max_tries
Total attempts, including the first. A retry pass re-sends only the entries that came back
rate_limited,timeout, or a 5xx, honoringRetry-Afterbetween passes. See the retry section onperform_many().- headers
A named list of headers, all marked sensitive.
- throttle
A throttle spec. See
req_defaults().- max_active
Maximum requests in flight at once.
- progress
Passed to
httr2::req_perform_parallel().FALSEby default, because the usual caller is a Shiny app that renders its own.- secret_query
A named list of query-string credentials, applied to every request in the batch at dispatch. See
redact_secrets().- ttl
Seconds a cached success stays fresh, applied to every entry in the batch.
NULL, the default, means the configured lifetime fromBIOHTTP_CACHE_TTL. Seecached().
Value
A list of envelopes, the same length and order as queries, each
with a single string in data on success.
Details
The keys are built exactly the way get_text() builds its own, so a batch
reuses a file a single call already fetched and the other way around.
Send requests for one host, and pass a throttle. perform_many() explains
both.
Examples
cache_reset()
breaker_reset()
httr2::with_mocked_responses(
function(req) {
httr2::response(
status_code = 200,
body = charToRaw("gene\tscore\n")
)
},
length(get_text_many(
"https://search.clinicalgenome.org",
path = c("kb/gene-validity/download", "kb/dosage/download"),
queries = list(list(), list()),
source = "ClinGen"
))
)
#> [1] 2