Skip to main content

CURRENT_PRINCIPAL

Static CURRENT_PRINCIPAL 

Source
pub static CURRENT_PRINCIPAL: LocalKey<Arc<Principal>>
Expand description

Tokio task-local carrying the authenticated principal for the in-flight query.

Set by the host-crate execute boundaries (Session::query, Transaction::query, Transaction::execute) so procedure invocation sites can populate ProcedureContext::with_principal without threading the principal through every internal API. Read at uni-query’s procedure-call paths immediately before calling plugin.invoke(ctx, ...).

Propagates across .await points within the same task tree; does NOT propagate across tokio::spawn. The synthetic procedure body bridge (block_in_place + Handle::block_on) stays on the same task so the principal remains visible to any nested execute_inner_query calls.