Skip to main content

Runtime

Struct Runtime 

Source
pub struct Runtime { /* private fields */ }
Expand description

The top-level NextVision runtime.

Manages cross-feed concerns: feed registry, global limits, and shutdown. Create via Runtime::builder().

Use handle() to obtain a cloneable RuntimeHandle for concurrent control from multiple threads. The Runtime itself can also be used directly for convenience.

Implementations§

Source§

impl Runtime

Source

pub fn builder() -> RuntimeBuilder

Create a new RuntimeBuilder.

Source

pub fn handle(&self) -> RuntimeHandle

Obtain a cloneable RuntimeHandle.

The handle provides the same control surface as Runtime but can be cloned and shared across threads.

Source

pub fn feed_count(&self) -> Result<usize, NvError>

Number of currently active feeds.

§Errors

Returns RuntimeError::RegistryPoisoned if the internal lock is poisoned.

Source

pub fn max_feeds(&self) -> usize

Maximum allowed concurrent feeds.

Source

pub fn uptime(&self) -> Duration

Elapsed time since the runtime was created.

Monotonically increasing. Useful for uptime dashboards and health checks.

Source

pub fn diagnostics(&self) -> Result<RuntimeDiagnostics, NvError>

Get a consolidated diagnostics snapshot of the runtime and all feeds.

Returns per-feed lifecycle state, metrics, queue depths, decode status, and view-system health, plus batch coordinator metrics and output channel lag status.

Designed for periodic polling (1–5 s) by dashboards and health probes. Complement with health_subscribe() for event-driven state transitions.

§Errors

Returns RuntimeError::RegistryPoisoned if an internal lock is poisoned.

Source

pub fn health_subscribe(&self) -> Receiver<HealthEvent>

Subscribe to aggregate health events from all feeds.

Source

pub fn output_subscribe(&self) -> Receiver<SharedOutput>

Subscribe to aggregate output from all feeds.

Each subscriber receives an Arc<OutputEnvelope> for every output produced by any feed. The channel is bounded by the configured output_capacity (default 256). Slow subscribers will receive RecvError::Lagged when they fall behind.

Channel saturation is monitored by an internal sentinel receiver. When the sentinel detects ring-buffer wrap, the runtime emits a global HealthEvent::OutputLagged event carrying the sentinel-observed per-event delta. This is a saturation signal, not a per-subscriber loss report. Live saturation state is also available via Runtime::diagnostics() in RuntimeDiagnostics::output_lag.

Source

pub fn add_feed(&self, config: FeedConfig) -> Result<FeedHandle, NvError>

Add a new feed to the runtime.

§Errors
  • RuntimeError::FeedLimitExceeded if the max feed count is reached.
  • RuntimeError::ShutdownInProgress if shutdown has been initiated.
  • RuntimeError::ThreadSpawnFailed if the OS thread cannot be created.
Source

pub fn create_batch( &self, processor: Box<dyn BatchProcessor>, config: BatchConfig, ) -> Result<BatchHandle, NvError>

Create a shared batch coordinator for cross-feed inference.

Returns a clonable BatchHandle that can be shared across multiple feeds via FeedPipeline::builder().batch(handle).

The coordinator takes ownership of the processor (via Box). A single coordinator thread is the sole caller of all processor methods — no Sync bound is required. The coordinator is shut down automatically when the runtime shuts down.

§Errors
  • RuntimeError::ShutdownInProgress if shutdown has been initiated.
  • ConfigError::DuplicateBatchProcessorId if a coordinator with the same processor ID already exists.
  • ConfigError::InvalidPolicy if config has invalid values.
  • RuntimeError::ThreadSpawnFailed if the coordinator thread fails.
Source

pub fn remove_feed(&self, feed_id: FeedId) -> Result<(), NvError>

Remove a feed by ID, stopping it gracefully.

§Errors

Returns RuntimeError::FeedNotFound if the ID does not exist.

Source

pub fn shutdown(self) -> Result<(), NvError>

Initiate graceful shutdown of all feeds.

Signals all worker threads to stop, waits for them to terminate, and returns. After shutdown the runtime cannot accept new feeds.

Trait Implementations§

Source§

impl Drop for Runtime

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more