pub struct CallContext {
pub server_id: String,
pub method: String,
pub request_id: String,
pub transport_metadata: Arc<Metadata>,
pub auth: AuthContext,
pub cookies: BTreeMap<String, String>,
pub kind: Option<TransportKind>,
/* private fields */
}Expand description
Context supplied to each handler invocation.
Fields§
§server_id: String§method: String§request_id: String§transport_metadata: Arc<Metadata>§auth: AuthContextAuthentication state, or crate::AuthContext::anonymous when
no authenticator is configured (e.g. pipe/unix transports).
HTTP request cookies (empty for pipe/unix). Name → value.
kind: Option<TransportKind>Coarse identifier of the bound transport. None until the
framework has observed the transport (i.e. before the first
RpcServer::notify_transport call).
Implementations§
Source§impl CallContext
impl CallContext
pub fn client_log(&self, level: LogLevel, message: impl Into<String>)
pub fn client_log_with(&self, msg: LogMessage)
Sourcepub fn tick_metadata(&self, key: &str) -> Option<String>
pub fn tick_metadata(&self, key: &str) -> Option<String>
Per-tick input-batch custom metadata value (e.g. vgi_pushdown_filters),
set by the producer/exchange loop for the current iteration.
Sourcepub fn session<T: Any + Send + Sync>(&self) -> Option<Arc<T>>
pub fn session<T: Any + Send + Sync>(&self) -> Option<Arc<T>>
The live session state object, downcast to T, or None when no
session is bound to this request (or it is not a T).
Sticky sessions are HTTP-only; on other transports this is always
None. Mirrors Python’s ctx.session.
Sourcepub fn session_id(&self) -> Option<String>
pub fn session_id(&self) -> Option<String>
The opaque hex session id bound to this request, or None.
Survives CallContext::close_session within the same request.
Sourcepub fn open_session(
&self,
state: Arc<dyn Any + Send + Sync>,
ttl: Option<Duration>,
) -> Result<()>
pub fn open_session( &self, state: Arc<dyn Any + Send + Sync>, ttl: Option<Duration>, ) -> Result<()>
Register a sticky session holding state for subsequent requests.
The framework mints a signed VGI-Session token and attaches it to
the response; a client inside a with_session_token() block echoes
it on subsequent requests, and the framework restores state as
CallContext::session. ttl overrides the server default.
Mirrors Python’s ctx.open_session. Errors when sticky is
unavailable on this transport, the client did not opt in, or a
session is already bound to this request.
Sourcepub fn close_session(&self) -> Result<()>
pub fn close_session(&self) -> Result<()>
Invalidate the sticky session bound to this request. Idempotent;
mirrors Python’s ctx.close_session.
Trait Implementations§
Source§impl Clone for CallContext
impl Clone for CallContext
Source§fn clone(&self) -> CallContext
fn clone(&self) -> CallContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more