pub struct TaskContext(/* private fields */);Expand description
Resolve dependencies OUTSIDE an HTTP request — background jobs, startup
wiring, CLI commands. Built from BuiltApp::task_context.
Resolution semantics mirror a request (memoized per context, honors
overrides and singletons), but only app-level providers are in scope,
and any factory reaching for an HTTP extractor (Json/Path/Query/
Headers) fails with JC1003.
Implementations§
Source§impl TaskContext
impl TaskContext
Sourcepub async fn resolve<T: Send + Sync + 'static>(&mut self) -> Result<Arc<T>>
pub async fn resolve<T: Send + Sync + 'static>(&mut self) -> Result<Arc<T>>
Resolve a dependency by type, memoized for this task context. Mirrors
RequestCtx::resolve; returns the same Arc<T> Dep<T> would carry.
Sourcepub fn fork(&self) -> TaskContext
pub fn fork(&self) -> TaskContext
A sibling task context sharing the app-level providers but with a fresh dependency-resolution cache — the job worker forks one per job so cached deps never leak between jobs.
The new context reuses the same Arc<DepEnv> (singletons + factories)
and the same Arc of overrides, so it resolves identical singletons; it
gets an empty cache, so request-scope factories run afresh and per-job
state is isolated.