Skip to main content

Module context

Module context 

Source
Expand description

Execution context for tasks running inside a rustvello runner.

Provides tokio::task_local! context so that a running task can discover its own invocation identity, workflow membership, and the runner that is executing it. This mirrors pynenc’s context.py module.

§Usage

The [TaskRunner] sets both contexts before executing a task:

use rustvello_core::context::*;

INVOCATION_CTX.scope(inv_ctx, RUNNER_CTX.scope(run_ctx, async {
    // inside here, get_invocation_context() returns Some(...)
    let ctx = get_invocation_context().unwrap();
})).await;

When a task calls app.call() inside its body, the app layer reads the current InvocationContext to determine parent/workflow inheritance.

Structs§

InvocationContext
Context for the currently executing invocation.
RunnerContext
Context identifying the runner that is executing the current task.

Statics§

INVOCATION_CTX
The invocation context for the currently running task.
RUNNER_CTX
The runner context for the current execution environment.

Functions§

clear_thread_invocation_context
Clear the thread-local invocation context.
clear_thread_runner_context
Clear the thread-local runner context.
get_invocation_context
Get the current invocation context, if running inside a task.
get_or_create_runner_context
Get the full runner context for the current execution.
get_or_create_runner_id
Get the runner ID for the current execution context.
get_runner_context
Get the current runner context, if set.
set_thread_invocation_context
Set the thread-local invocation context (for use before spawn_blocking).
set_thread_runner_context
Set the thread-local runner context (for use before spawn_blocking).
with_invocation_context
Access the current invocation context by reference, avoiding a clone when the tokio task-local is available.
with_runner_context
Access the current runner context by reference, avoiding a clone.