Struct Plugin Runtime

View as Markdown

Generated from cargo doc --no-deps -p nemo-relay -p nemo-relay-adaptive -p nemo-relay-pii-redaction -p nemo-relay-ffi -p nemo-relay-types -p nemo-relay-plugin -p nemo-relay-worker-proto -p nemo-relay-worker.

pub struct PluginRuntime { /* private fields */ }

Cloneable handle for calling the Relay host runtime from worker callbacks.

Implementations

impl PluginRuntime

impl PluginRuntime

log

pub async fn log(
    &self,
    level: PluginLogLevel,
    target: &str,
    message: &str,
    fields: Option<&Map<String, Json>>,
) -> Result<()>

Emits one operational log record through the Relay host’s configured sinks.

The host authenticates the activation and applies its own log-level filter. target identifies the plugin subsystem; pass an empty string to use the plugin’s default target.

trace

pub async fn trace(
    &self,
    target: &str,
    message: &str,
    fields: Option<&Map<String, Json>>,
) -> Result<()>

Emits an info-level operational log record through the Relay host.

debug

pub async fn debug(
    &self,
    target: &str,
    message: &str,
    fields: Option<&Map<String, Json>>,
) -> Result<()>

Emits a debug-level operational log record through the Relay host.

info

pub async fn info(
    &self,
    target: &str,
    message: &str,
    fields: Option<&Map<String, Json>>,
) -> Result<()>

Emits an info-level operational log record through the Relay host.

warn

pub async fn warn(
    &self,
    target: &str,
    message: &str,
    fields: Option<&Map<String, Json>>,
) -> Result<()>

Emits a warn-level operational log record through the Relay host.

error

pub async fn error(
    &self,
    target: &str,
    message: &str,
    fields: Option<&Map<String, Json>>,
) -> Result<()>

Emits an error-level operational log record through the Relay host.

list_runtime_registrations

pub async fn list_runtime_registrations(
    &self,
    kinds: Option<BTreeSet<RuntimeRegistrationKind>>,
) -> Result<Vec<RuntimeRegistrationIdentity>>

List global runtime registrations, optionally filtered by kind.

register_conditional_middleware_guardrail

pub async fn register_conditional_middleware_guardrail<F, Fut>(
    &self,
    name: &str,
    kinds: BTreeSet<RuntimeRegistrationKind>,
    registration_name: &str,
    callback: F,
) -> Result<ConditionalMiddlewareGuardrailHandle>where
    F: Fn(BTreeSet<RuntimeRegistrationKind>, String) -> Fut + Send + Sync + 'static,
    Fut: Future<Output = Result<Option<String>>> + Send + 'static,

Register a callback-based gate owned by this worker activation.

deregister_conditional_middleware_guardrail

pub async fn deregister_conditional_middleware_guardrail(
    &self,
    handle: &ConditionalMiddlewareGuardrailHandle,
) -> Result<bool>

Deregister a callback-based gate owned by this worker activation.

emit_mark

pub async fn emit_mark(
    &self,
    name: &str,
    data: Option<Json>,
    metadata: Option<Json>,
) -> Result<()>

Emits a mark event through the host runtime.

emit_mark_with_options

pub async fn emit_mark_with_options(
    &self,
    name: &str,
    data: Option<Json>,
    metadata: Option<Json>,
    options: EmitMarkOptions,
) -> Result<()>

Emits a mark event through the host runtime with optional schema and severity fields.

emit_mark_with_options_and_category

pub async fn emit_mark_with_options_and_category(
    &self,
    name: &str,
    data: Option<Json>,
    metadata: Option<Json>,
    options: EmitMarkOptions,
    category: EventCategory,
) -> Result<()>

Emits a mark event through the host runtime with optional schema, severity, and category.

runtime_diagnostics

pub async fn runtime_diagnostics(&self) -> Result<RuntimeDiagnostics>

Return a bounded snapshot of active host runtime diagnostics.

emit_metric

pub async fn emit_metric(
    &self,
    name: &str,
    measurements: Vec<MetricMeasurement>,
    metadata: Option<Json>,
) -> Result<()>

Emits a validated Relay metric-measurement mark through the host runtime.

emit_metric_with_category

pub async fn emit_metric_with_category(
    &self,
    name: &str,
    measurements: Vec<MetricMeasurement>,
    metadata: Option<Json>,
    category: EventCategory,
) -> Result<()>

Emits a validated Relay metric-measurement mark with an event category.

create_scope_stack

pub async fn create_scope_stack(&self) -> Result<String>

Creates an isolated host-owned scope stack.

drop_scope_stack

pub async fn drop_scope_stack(&self, scope_stack_id: &str) -> Result<()>

Drops an isolated host-owned scope stack.

with_scope_stack

pub async fn with_scope_stack<F, Fut, T>(&self, scope_stack_id: &str, f: F) -> Twhere
    F: FnOnce() -> Fut,
    Fut: Future<Output = T>,

Runs an async operation with runtime calls bound to a specific host-owned scope stack.

This is useful for isolated stacks created with Self::create_scope_stack. The previous worker invocation scope is restored after the future completes.

push_scope

pub async fn push_scope(
    &self,
    scope_stack_id: Option<&str>,
    name: &str,
    scope_type: ScopeType,
    data: Option<Json>,
    metadata: Option<Json>,
    input: Option<Json>,
) -> Result<String>

Pushes a scope through the host runtime.

push_scope_at

pub async fn push_scope_at(
    &self,
    scope_stack_id: Option<&str>,
    name: &str,
    scope_type: ScopeType,
    data: Option<Json>,
    metadata: Option<Json>,
    input: Option<Json>,
    started_at: SystemTime,
) -> Result<String>

Pushes a scope through the host runtime using an explicit start time.

pop_scope

pub async fn pop_scope(
    &self,
    scope_handle_id: &str,
    output: Option<Json>,
    metadata: Option<Json>,
) -> Result<()>

Pops a scope through the host runtime.

pop_scope_at

pub async fn pop_scope_at(
    &self,
    scope_handle_id: &str,
    output: Option<Json>,
    metadata: Option<Json>,
    ended_at: SystemTime,
) -> Result<()>

Pops a scope through the host runtime using an explicit end time.

Trait Implementations

impl Clone for PluginRuntime

impl Clone for PluginRuntime

clone

fn clone(&self) -> PluginRuntime

clone_from

fn clone_from(&mut self, source: &Self)