pub struct ExecCtx {
pub client: Client,
pub base_url: String,
pub backend: Arc<dyn Backend>,
pub backoff: BackoffConfig,
pub vars: HashMap<String, String>,
pub cancellation: Option<Arc<AtomicBool>>,
pub event_handler: Option<Arc<dyn EventHandler>>,
pub trace_id: TraceId,
pub trace_ctx: TraceCtx,
pub limits: PipelineLimits,
}Expand description
Shared execution context for payload invocations.
Carries everything a payload needs from the runtime environment without coupling to any specific orchestrator (Pipeline, LangGraph, etc.).
§Example
use llm_pipeline::ExecCtx;
let ctx = ExecCtx::builder("http://localhost:11434")
.var("domain", "science")
.var("audience", "researchers")
.build();Fields§
§client: ClientHTTP client (cheap to clone – uses Arc internally).
base_url: StringBase URL for the LLM provider (e.g. http://localhost:11434).
backend: Arc<dyn Backend>LLM backend. Default: OllamaBackend.
backoff: BackoffConfigTransport retry configuration. Default: BackoffConfig::none().
vars: HashMap<String, String>Template variables substituted into prompt {key} placeholders.
cancellation: Option<Arc<AtomicBool>>Optional cancellation flag; payloads should check before starting.
event_handler: Option<Arc<dyn EventHandler>>Optional event handler for streaming tokens and lifecycle events.
trace_id: TraceIdUse trace_ctx instead. Will be removed when all callers migrate to TraceCtx.
Phase status: compatibility / migration-only
Legacy trace ID for correlating this context’s operations across crates.
Auto-generated if not provided. Use trace_ctx for
the canonical trace form on the normal path.
Removal condition: removed when all callers migrate to TraceCtx.
trace_ctx: TraceCtxCanonical trace context from stack_ids.
This is the normal-path trace form. It supports parent span tracking,
bounded baggage, and W3C traceparent serialization. Automatically
generated from trace_id if not explicitly set.
limits: PipelineLimitsResource limits for pipeline operations.
Implementations§
Source§impl ExecCtx
impl ExecCtx
Sourcepub fn builder(base_url: impl Into<String>) -> ExecCtxBuilder
pub fn builder(base_url: impl Into<String>) -> ExecCtxBuilder
Create a new builder.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check whether cancellation has been requested.
Sourcepub fn check_cancelled(&self) -> Result<()>
pub fn check_cancelled(&self) -> Result<()>
Return an error if cancellation has been requested.
Sourcepub fn cancel_flag(&self) -> Option<&AtomicBool>
pub fn cancel_flag(&self) -> Option<&AtomicBool>
Get a reference to the cancellation AtomicBool, if set.