Expand description
§MAD - Lifecycle Manager for Rust Applications
A simple lifecycle manager for long-running Rust applications. Run multiple services concurrently with graceful shutdown handling.
§Quick Start
use notmad::{Component, Mad};
use tokio_util::sync::CancellationToken;
struct MyService;
impl Component for MyService {
async fn run(&self, cancel: CancellationToken) -> Result<(), notmad::MadError> {
println!("Running...");
cancel.cancelled().await;
println!("Stopped");
Ok(())
}
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
Mad::builder()
.add(MyService)
.run()
.await?;
Ok(())
}§Features
- Run multiple components concurrently
- Graceful shutdown with cancellation tokens
- Optional lifecycle hooks:
setup(),run(),close() - Automatic error aggregation
- SIGTERM and Ctrl+C signal handling
Structs§
- Aggregate
Error - Container for multiple errors from different components.
- Component
Info - Mad
- The main lifecycle manager for running multiple components.
- Shared
Component
Enums§
- MadError
- Error type for MAD operations.
Traits§
- Component
- Trait for implementing MAD components.
- Into
Component - Trait for converting types into components.