Struct RingKernelContext
pub struct RingKernelContext {Show 16 fields
config: RingKernelConfig,
health_checker: Arc<HealthChecker>,
watchdog: Arc<KernelWatchdog>,
circuit_breaker: Arc<CircuitBreaker>,
degradation_manager: Arc<DegradationManager>,
prometheus_exporter: Arc<PrometheusExporter>,
observability: Arc<ObservabilityContext>,
multi_gpu_coordinator: Arc<MultiGpuCoordinator>,
migrator: Arc<KernelMigrator>,
checkpoint_storage: Arc<dyn CheckpointStorage>,
stats: RuntimeStats,
started_at: Instant,
running: AtomicBool,
lifecycle_state: RwLock<RawRwLock, LifecycleState>,
background_tasks: BackgroundTasks,
shutdown_requested: AtomicBool,
}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:
Initializing→Running→Draining→ShuttingDown→Stopped
Use start_monitoring() to begin background health checks and watchdog scans.
Use shutdown() for graceful termination.
Fields§
§config: RingKernelConfig§health_checker: Arc<HealthChecker>§watchdog: Arc<KernelWatchdog>§circuit_breaker: Arc<CircuitBreaker>§degradation_manager: Arc<DegradationManager>§prometheus_exporter: Arc<PrometheusExporter>§observability: Arc<ObservabilityContext>§multi_gpu_coordinator: Arc<MultiGpuCoordinator>§migrator: Arc<KernelMigrator>§checkpoint_storage: Arc<dyn CheckpointStorage>§stats: RuntimeStats§started_at: Instant§running: AtomicBool§lifecycle_state: RwLock<RawRwLock, LifecycleState>§background_tasks: BackgroundTasks§shutdown_requested: AtomicBoolImplementations§
§impl RingKernelContext
impl RingKernelContext
pub fn config(&self) -> &RingKernelConfig
pub fn config(&self) -> &RingKernelConfig
Get the configuration.
pub fn health_checker(&self) -> Arc<HealthChecker>
pub fn health_checker(&self) -> Arc<HealthChecker>
Get the health checker.
pub fn watchdog(&self) -> Arc<KernelWatchdog>
pub fn watchdog(&self) -> Arc<KernelWatchdog>
Get the kernel watchdog.
pub fn circuit_breaker(&self) -> Arc<CircuitBreaker>
pub fn circuit_breaker(&self) -> Arc<CircuitBreaker>
Get the circuit breaker.
pub fn degradation_manager(&self) -> Arc<DegradationManager>
pub fn degradation_manager(&self) -> Arc<DegradationManager>
Get the degradation manager.
pub fn prometheus_exporter(&self) -> Arc<PrometheusExporter>
pub fn prometheus_exporter(&self) -> Arc<PrometheusExporter>
Get the Prometheus exporter.
pub fn observability(&self) -> Arc<ObservabilityContext>
pub fn observability(&self) -> Arc<ObservabilityContext>
Get the observability context.
pub fn multi_gpu_coordinator(&self) -> Arc<MultiGpuCoordinator>
pub fn multi_gpu_coordinator(&self) -> Arc<MultiGpuCoordinator>
Get the multi-GPU coordinator.
pub fn migrator(&self) -> Arc<KernelMigrator>
pub fn migrator(&self) -> Arc<KernelMigrator>
Get the kernel migrator.
pub fn checkpoint_storage(&self) -> Arc<dyn CheckpointStorage>
pub fn checkpoint_storage(&self) -> Arc<dyn CheckpointStorage>
Get the checkpoint storage.
pub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if the runtime is running.
pub fn stats(&self) -> RuntimeStatsSnapshot
pub fn stats(&self) -> RuntimeStatsSnapshot
Get runtime statistics.
pub fn record_kernel_launch(&self)
pub fn record_kernel_launch(&self)
Record a kernel launch.
pub fn record_messages(&self, count: u64)
pub fn record_messages(&self, count: u64)
Record messages processed.
pub fn record_migration(&self)
pub fn record_migration(&self)
Record a migration completion.
pub fn record_checkpoint(&self)
pub fn record_checkpoint(&self)
Record a checkpoint creation.
pub fn record_health_check(&self)
pub fn record_health_check(&self)
Record a health check run.
pub fn record_circuit_trip(&self)
pub fn record_circuit_trip(&self)
Record a circuit breaker trip.
pub fn lifecycle_state(&self) -> LifecycleState
pub fn lifecycle_state(&self) -> LifecycleState
Get the current lifecycle state.
pub fn is_shutdown_requested(&self) -> bool
pub fn is_shutdown_requested(&self) -> bool
Check if shutdown has been requested.
pub fn is_accepting_work(&self) -> bool
pub fn is_accepting_work(&self) -> bool
Check if the runtime is accepting new work.
pub fn start(&self) -> Result<(), RingKernelError>
pub fn start(&self) -> Result<(), RingKernelError>
Transition to running state.
Call this after initialization is complete to start accepting work.
pub fn run_health_check_cycle(&self) -> HealthCycleResult
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.
pub fn run_watchdog_cycle(&self) -> WatchdogResult
pub fn run_watchdog_cycle(&self) -> WatchdogResult
Run a single watchdog scan cycle.
This checks for stale kernels and takes appropriate action.
pub fn flush_metrics(&self) -> String
pub fn flush_metrics(&self) -> String
Flush metrics to Prometheus.
This renders current metrics to the Prometheus exporter format.
pub fn background_task_status(&self) -> BackgroundTaskStatus
pub fn background_task_status(&self) -> BackgroundTaskStatus
Get background task status.
pub fn start_monitoring(
self: &Arc<RingKernelContext>,
config: MonitoringConfig,
) -> MonitoringHandles
pub fn start_monitoring( self: &Arc<RingKernelContext>, 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;pub fn start_monitoring_default(
self: &Arc<RingKernelContext>,
) -> MonitoringHandles
pub fn start_monitoring_default( self: &Arc<RingKernelContext>, ) -> MonitoringHandles
Start monitoring with default configuration.
pub fn request_shutdown(&self) -> Result<(), RingKernelError>
pub fn request_shutdown(&self) -> Result<(), RingKernelError>
Request graceful shutdown.
This signals background tasks to stop and transitions to draining state.
Returns immediately; use wait_for_shutdown() to block until complete.
pub fn complete_shutdown(&self) -> Result<ShutdownReport, RingKernelError>
pub fn complete_shutdown(&self) -> Result<ShutdownReport, RingKernelError>
Complete the shutdown process.
This performs final cleanup and transitions to stopped state.
pub fn shutdown(&self) -> Result<(), RingKernelError>
pub fn shutdown(&self) -> Result<(), RingKernelError>
Shutdown the runtime gracefully (legacy method).
This is equivalent to request_shutdown() followed by complete_shutdown().
§impl RingKernelContext
impl RingKernelContext
pub fn export_metrics(&self) -> String
pub fn export_metrics(&self) -> String
Export Prometheus metrics.
pub fn metrics_snapshot(&self) -> ContextMetrics
pub fn metrics_snapshot(&self) -> ContextMetrics
Create a metrics snapshot for the runtime context.
Auto Trait Implementations§
impl !Freeze for RingKernelContext
impl !RefUnwindSafe for RingKernelContext
impl Send for RingKernelContext
impl Sync for RingKernelContext
impl Unpin for RingKernelContext
impl !UnwindSafe for RingKernelContext
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more