Expand description
Runtime Lifecycle Management
This module provides runtime lifecycle management for RustKernels, including:
- Runtime configuration and initialization
- Graceful shutdown with drain periods
- Hot configuration reload
- Runtime state machine management
§Architecture
The runtime is built on ringkernel 0.3.1’s RingKernelRuntime with additional
enterprise features for production deployments:
- Lifecycle States:
Created→Starting→Running→Draining→Stopped - Configuration: Environment variables, files, and programmatic configuration
- Graceful Shutdown: Configurable drain period to complete in-flight requests
§Example
ⓘ
use rustkernel_core::runtime::{KernelRuntime, RuntimeConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create runtime with production configuration
let runtime = KernelRuntime::builder()
.production()
.with_drain_timeout(Duration::from_secs(30))
.build()
.await?;
// Start the runtime
runtime.start().await?;
// ... use runtime ...
// Graceful shutdown
runtime.shutdown().await?;
Ok(())
}Re-exports§
pub use config::BackendConfig;pub use config::RuntimeConfig;pub use config::RuntimeConfigBuilder;pub use lifecycle::KernelRuntime;pub use lifecycle::LifecycleState;pub use lifecycle::RuntimeBuilder;pub use lifecycle::RuntimeHandle;
Modules§
Structs§
- Runtime
Stats - Runtime statistics
Enums§
- Runtime
Event - Runtime event types for lifecycle hooks
- Runtime
Preset - Runtime presets for common deployment scenarios
Constants§
- DEFAULT_
DRAIN_ TIMEOUT - Default drain timeout for graceful shutdown
- DEFAULT_
HEALTH_ CHECK_ INTERVAL - Default health check interval
Functions§
- shutdown_
channel - Create a shutdown signal channel
Type Aliases§
- Runtime
Event Callback - Callback for runtime events
- Shutdown
Signal - Shutdown signal receiver