Skip to main content

Crate notmad

Crate notmad 

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

AggregateError
Container for multiple errors from different components.
ComponentInfo
Mad
The main lifecycle manager for running multiple components.
SharedComponent

Enums§

MadError
Error type for MAD operations.

Traits§

Component
Trait for implementing MAD components.
IntoComponent
Trait for converting types into components.