Provides a process-wide multi-threaded Tokio runtime for executing asynchronous tasks and HTTP requests. Reuse when managing shared async background workers in Rust.
// Source: https://github.com/cachix/secretspec | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
/// Process-wide runtime for provider SDK and HTTP work.
///
/// `get_many` invokes its synchronous fetch closures from several OS threads.
/// Running each call on the caller's runtime, or on a temporary one, can
/// strand pooled connections and background tasks when that runtime is
/// dropped. One long-lived runtime keeps them alive across requests and
/// providers.
fn runtime() -> &'static tokio::runtime::Runtime {
static PROVIDER_RUNTIME: std::sync::LazyLock<tokio::runtime::Runtime> =
std::sync::LazyLock::new(|| {
tokio::runtime::Builder::new_multi_thread(
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key