Perform multiple requests with configurable concurrency strategy
Source:R/core.R
perform_requests_with_strategy.RdExecutes a list of HTTP requests either sequentially or in parallel. Automatically chooses sequential processing when concurrent_requests = 1 or when there's only one request.
Value
List of httr2_response objects (check status with resp_status()) or error objects for network failures
Details
Returns responses in the order that requests were sent. Since requests use req_error(is_error = ~ FALSE), HTTP error responses (status >= 400) are returned as httr2_response objects rather than being thrown as errors. Callers should check response status with httr2::resp_status() or use httr2::resps_successes() / httr2::resps_failures() to categorise responses.
Examples
if (FALSE) { # \dontrun{
# Sequential processing
responses <- perform_requests_with_strategy(
requests = my_requests,
concurrent_requests = 1
)
# Parallel processing with 5 concurrent requests
responses <- perform_requests_with_strategy(
requests = my_requests,
concurrent_requests = 5,
progress = TRUE
)
} # }