biohttp: Normalized HTTP Transport with Circuit Breaking and Caching
Source:R/biohttp-package.R
biohttp-package.RdWeb service calls return a normalized result value instead of raising a condition, so a caller branches on data rather than on an error handler. Transport failure, a non-success status code, and an unreadable response body are reported as three distinct outcomes. Per-host circuit breaking, retry with a transient-failure predicate, optional throttling, redacted request headers, and a success-only cache come as defaults. Many questions to one source can be asked as a single batch, where only the entries the cache is missing reach the network. Service specific knowledge is left to the client packages built on top.
Details
Start at get_json(), post_json(), or get_text() for a call that
assembles, performs, and caches itself. Drop to perform() when you need to
build the request yourself, and pass it through req_defaults() first.
Every one of them returns an envelope() rather than raising, so a client
branches on res$status and writes no tryCatch() of its own.
On the jsonlite import
jsonlite is imported but never called here, because httr2 calls it on this
package's behalf: httr2::resp_body_json() does
check_installed("jsonlite") at runtime, and httr2 keeps it in Suggests
rather than Imports. Declaring it is what stops get_json() failing on a
clean install. The import below is what makes that declaration honest to
R CMD check.
Author
Maintainer: Samuel Bharti samuelbharti.io@gmail.com (ORCID) [copyright holder]
Authors:
Samuel Bharti samuelbharti.io@gmail.com (ORCID) [copyright holder]