Go to file
Kasper Juul Hermansen 0b5f19fc77
All checks were successful
continuous-integration/drone/push Build is passing
fix(deps): update rust crate thiserror to v2.0.6 (#19)
2024-12-09 06:48:37 +01:00
crates/mad fix: make sure to close on final 2024-11-24 11:24:13 +01:00
.drone.yml feat: add basic 2024-08-06 22:22:46 +02:00
.gitignore feat: add basic 2024-08-06 22:22:46 +02:00
Cargo.lock fix(deps): update rust crate thiserror to v2.0.6 (#19) 2024-12-09 06:48:37 +01:00
Cargo.toml chore(release): v0.7.1 (#12) 2024-11-24 11:28:02 +01:00
CHANGELOG.md chore(release): v0.7.1 (#12) 2024-11-24 11:28:02 +01:00
cuddle.yaml feat: add basic 2024-08-06 22:22:46 +02:00
README.md docs: add examples 2024-08-07 17:09:52 +02:00
renovate.json chore: Configure Renovate (#7) 2024-11-24 00:26:37 +01:00

MAD

Mad is a life-cycle manager for long running rust operations.

  • Webservers
  • Queue bindings
  • gRPC servers etc
  • Cron runners

It is supposed to be the main thing the application runs, and everything from it is spawned and managed by it.

struct WaitServer {}

#[async_trait]
impl Component for WaitServer {
    fn name(&self) -> Option<String> {
        Some("NeverEndingRun".into())
    }

    async fn run(&self, cancellation: CancellationToken) -> Result<(), mad::MadError> {
        let millis_wait = rand::thread_rng().gen_range(50..1000);

        // Simulates a server running for some time. Is normally supposed to be futures blocking indefinitely
        tokio::time::sleep(std::time::Duration::from_millis(millis_wait)).await;

        Ok(())
    }
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    Mad::builder()
        .add(WaitServer {})
        .add(WaitServer {})
        .add(WaitServer {})
        .run()
        .await?;

    Ok(())
}

Examples

Can be found (here)[crates/mad/examples]

  • basic
  • fn
  • signals
  • error_log