Skip to main content

RingKernelContext

Struct RingKernelContext 

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

Unified runtime context managing all enterprise features.

This is the main entry point for using RingKernel’s enterprise features. It instantiates and manages:

  • Health checking and circuit breakers
  • Prometheus metrics exporter
  • Multi-GPU coordination
  • Kernel migration infrastructure
  • Background monitoring tasks

§Lifecycle

The runtime goes through these states:

  • InitializingRunningDrainingShuttingDownStopped

Use start_monitoring() to begin background health checks and watchdog scans. Use shutdown() for graceful termination.

Implementations§

Source§

impl RingKernelContext

Source

pub fn config(&self) -> &RingKernelConfig

Get the configuration.

Source

pub fn health_checker(&self) -> Arc<HealthChecker>

Get the health checker.

Source

pub fn watchdog(&self) -> Arc<KernelWatchdog>

Get the kernel watchdog.

Source

pub fn circuit_breaker(&self) -> Arc<CircuitBreaker>

Get the circuit breaker.

Source

pub fn degradation_manager(&self) -> Arc<DegradationManager>

Get the degradation manager.

Source

pub fn prometheus_exporter(&self) -> Arc<PrometheusExporter>

Get the Prometheus exporter.

Source

pub fn observability(&self) -> Arc<ObservabilityContext>

Get the observability context.

Source

pub fn multi_gpu_coordinator(&self) -> Arc<MultiGpuCoordinator>

Get the multi-GPU coordinator.

Source

pub fn migrator(&self) -> Arc<KernelMigrator>

Get the kernel migrator.

Source

pub fn checkpoint_storage(&self) -> Arc<dyn CheckpointStorage>

Get the checkpoint storage.

Source

pub fn is_running(&self) -> bool

Check if the runtime is running.

Source

pub fn uptime(&self) -> Duration

Get runtime uptime.

Source

pub fn stats(&self) -> RuntimeStatsSnapshot

Get runtime statistics.

Source

pub fn record_kernel_launch(&self)

Record a kernel launch.

Source

pub fn record_messages(&self, count: u64)

Record messages processed.

Source

pub fn record_migration(&self)

Record a migration completion.

Source

pub fn record_checkpoint(&self)

Record a checkpoint creation.

Source

pub fn record_health_check(&self)

Record a health check run.

Source

pub fn record_circuit_trip(&self)

Record a circuit breaker trip.

Source

pub fn lifecycle_state(&self) -> LifecycleState

Get the current lifecycle state.

Source

pub fn is_shutdown_requested(&self) -> bool

Check if shutdown has been requested.

Source

pub fn is_accepting_work(&self) -> bool

Check if the runtime is accepting new work.

Source

pub fn start(&self) -> Result<()>

Transition to running state.

Call this after initialization is complete to start accepting work.

Source

pub fn run_health_check_cycle(&self) -> HealthCycleResult

Run a single health check cycle.

This performs one round of health checks and updates the circuit breaker and degradation manager based on the results.

Note: This is a synchronous method that uses cached circuit breaker state. For full async health checks, use the HealthChecker directly.

Source

pub fn run_watchdog_cycle(&self) -> WatchdogResult

Run a single watchdog scan cycle.

This checks for stale kernels and takes appropriate action.

Source

pub fn flush_metrics(&self) -> String

Flush metrics to Prometheus.

This renders current metrics to the Prometheus exporter format.

Source

pub fn background_task_status(&self) -> BackgroundTaskStatus

Get background task status.

Source

pub fn start_monitoring( self: &Arc<Self>, config: MonitoringConfig, ) -> MonitoringHandles

Start background monitoring loops.

This spawns async tasks for:

  • Health check loop (runs at configured interval)
  • Watchdog loop (checks for stale kernels)
  • Metrics flush loop (exports Prometheus metrics)

Returns handles that can be used to stop the monitoring tasks.

§Example
let runtime = RuntimeBuilder::new().production().build()?;
runtime.start()?;

let config = MonitoringConfig::new()
    .health_check_interval(Duration::from_secs(5))
    .watchdog_interval(Duration::from_secs(2));

let handles = runtime.start_monitoring(config).await;

// ... runtime runs ...

// Graceful shutdown
handles.signal_shutdown();
handles.wait_for_shutdown().await;
Source

pub fn start_monitoring_default(self: &Arc<Self>) -> MonitoringHandles

Start monitoring with default configuration.

Source

pub fn request_shutdown(&self) -> Result<()>

Request graceful shutdown.

This signals background tasks to stop and transitions to draining state. Returns immediately; use wait_for_shutdown() to block until complete.

Source

pub fn complete_shutdown(&self) -> Result<ShutdownReport>

Complete the shutdown process.

This performs final cleanup and transitions to stopped state.

Source

pub fn shutdown(&self) -> Result<()>

Shutdown the runtime gracefully (legacy method).

This is equivalent to request_shutdown() followed by complete_shutdown().

Source

pub fn app_info(&self) -> AppInfo

Get application info.

Source§

impl RingKernelContext

Source

pub fn export_metrics(&self) -> String

Export Prometheus metrics.

Source

pub fn metrics_snapshot(&self) -> ContextMetrics

Create a metrics snapshot for the runtime context.

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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
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> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
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