pub struct NemoRelayContextState { /* private fields */ }Expand description
Process-global runtime state backing middleware and event emission.
The public API layer stores one shared instance of this type for the process. It contains global middleware registries, lifecycle subscribers, and arbitrary extension slots used by bindings or integrations.
Implementations§
Source§impl NemoRelayContextState
impl NemoRelayContextState
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty runtime state with no registered middleware.
§Returns
A NemoRelayContextState with empty registries, no subscribers, and no
extensions.
Sourcepub fn set_extension<T: Any + Send + Sync>(
&mut self,
key: impl Into<String>,
value: T,
)
pub fn set_extension<T: Any + Send + Sync>( &mut self, key: impl Into<String>, value: T, )
Store an arbitrary runtime extension under key.
Extensions let bindings or integrations attach shared state to the process-global runtime without adding new first-class fields.
§Parameters
key: Stable identifier for the extension slot.value: Typed extension value to store.
Sourcepub fn remove_extension(&mut self, key: &str) -> bool
pub fn remove_extension(&mut self, key: &str) -> bool
Sourcepub fn create_event(&self, params: MarkEvent) -> Event
pub fn create_event(&self, params: MarkEvent) -> Event
Sourcepub fn create_scope_handle(
&self,
params: CreateScopeHandleParams<'_>,
) -> ScopeHandle
pub fn create_scope_handle( &self, params: CreateScopeHandleParams<'_>, ) -> ScopeHandle
Create a new scope handle.
§Parameters
name: Human-readable scope name.parent_uuid: Optional parent scope UUID.scope_type: Semantic category of the scope.attributes: Scope attribute bitflags.data: Optional application payload stored on the handle.metadata: Optional metadata stored on the handle.timestamp: Optional handle start time. When omitted, the current UTC time is used.
§Returns
A new ScopeHandle with a fresh UUID.
Sourcepub fn build_scope_start_event(
&self,
handle: &ScopeHandle,
data: Option<Json>,
) -> Event
pub fn build_scope_start_event( &self, handle: &ScopeHandle, data: Option<Json>, ) -> Event
Sourcepub fn end_scope_handle(
&self,
handle: &ScopeHandle,
data: Option<Json>,
metadata: Option<Json>,
) -> Event
pub fn end_scope_handle( &self, handle: &ScopeHandle, data: Option<Json>, metadata: Option<Json>, ) -> Event
Sourcepub fn build_scope_end_event(&self, params: EndScopeHandleParams<'_>) -> Event
pub fn build_scope_end_event(&self, params: EndScopeHandleParams<'_>) -> Event
Sourcepub fn create_tool_handle(
&self,
params: CreateToolHandleParams<'_>,
) -> ToolHandle
pub fn create_tool_handle( &self, params: CreateToolHandleParams<'_>, ) -> ToolHandle
Create a new tool handle.
§Parameters
name: Tool name recorded on emitted events.parent_uuid: Optional parent scope UUID.attributes: Tool attribute bitflags.data: Optional application payload stored on the handle.metadata: Optional metadata stored on the handle.tool_call_id: Optional provider-specific correlation identifier.timestamp: Optional handle start time. When omitted, the current UTC time is used.
§Returns
A new ToolHandle with a fresh UUID.
Sourcepub fn build_tool_start_event(
&self,
handle: &ToolHandle,
data: Option<Json>,
) -> Event
pub fn build_tool_start_event( &self, handle: &ToolHandle, data: Option<Json>, ) -> Event
Sourcepub fn end_tool_handle(
&self,
handle: &ToolHandle,
data: Option<Json>,
metadata: Option<Json>,
) -> Event
pub fn end_tool_handle( &self, handle: &ToolHandle, data: Option<Json>, metadata: Option<Json>, ) -> Event
Sourcepub fn build_tool_end_event(&self, params: EndToolHandleParams<'_>) -> Event
pub fn build_tool_end_event(&self, params: EndToolHandleParams<'_>) -> Event
Sourcepub fn create_llm_handle(&self, params: CreateLlmHandleParams<'_>) -> LlmHandle
pub fn create_llm_handle(&self, params: CreateLlmHandleParams<'_>) -> LlmHandle
Create a new LLM handle.
§Parameters
name: Logical provider or model family name. Gateway-managed LLM calls use provider route names such asanthropic.messages, which become the emitted event name.parent_uuid: Optional parent scope UUID.attributes: LLM attribute bitflags.data: Optional application payload stored on the handle.metadata: Optional metadata stored on the handle.model_name: Optional normalized model name stored on the handle.timestamp: Optional handle start time. When omitted, the current UTC time is used.
§Returns
A new LlmHandle with a fresh UUID.
Sourcepub fn build_llm_start_event(
&self,
handle: &LlmHandle,
data: Option<Json>,
annotated_request: Option<Arc<AnnotatedLlmRequest>>,
) -> Event
pub fn build_llm_start_event( &self, handle: &LlmHandle, data: Option<Json>, annotated_request: Option<Arc<AnnotatedLlmRequest>>, ) -> Event
Sourcepub fn end_llm_handle(
&self,
handle: &LlmHandle,
data: Option<Json>,
metadata: Option<Json>,
annotated_response: Option<Arc<AnnotatedLlmResponse>>,
) -> Event
pub fn end_llm_handle( &self, handle: &LlmHandle, data: Option<Json>, metadata: Option<Json>, annotated_response: Option<Arc<AnnotatedLlmResponse>>, ) -> Event
Build an LLM-end event from a handle and optional overrides.
§Parameters
handle: LLM handle to serialize into an event.data: Sanitized LLM response payload.metadata: Optional metadata payload merged overhandle.metadata.annotated_response: Optional normalized response annotation.
§Returns
An LLM-end Event derived from the provided handle.
Sourcepub fn build_llm_end_event(&self, params: EndLlmHandleParams<'_>) -> Event
pub fn build_llm_end_event(&self, params: EndLlmHandleParams<'_>) -> Event
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for NemoRelayContextState
impl !UnwindSafe for NemoRelayContextState
impl Freeze for NemoRelayContextState
impl Send for NemoRelayContextState
impl Sync for NemoRelayContextState
impl Unpin for NemoRelayContextState
impl UnsafeUnpin for NemoRelayContextState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request