| Crates.io | duende-core |
| lib.rs | duende-core |
| version | 0.2.0 |
| created_at | 2026-01-06 14:08:48.829389+00 |
| updated_at | 2026-01-13 12:16:23.482821+00 |
| description | Core daemon lifecycle primitives for the Duende framework |
| homepage | |
| repository | https://github.com/paiml/duende |
| max_upload_size | |
| id | 2025927 |
| size | 438,658 |
Core daemon lifecycle primitives for the Duende framework.
This crate provides foundational types and traits for cross-platform daemon management:
Daemon trait: Define daemon lifecycle (init, run, shutdown)DaemonConfig: Configuration with restart policies, health checksDaemonMetrics: RED method metrics (Rate, Errors, Duration)DaemonContext: Runtime context and signal handlingDaemonManager: Manages multiple daemons with supervisionuse duende_core::{Daemon, DaemonConfig, DaemonContext, DaemonId, ExitReason};
use async_trait::async_trait;
struct MyDaemon {
id: DaemonId,
}
#[async_trait]
impl Daemon for MyDaemon {
fn id(&self) -> DaemonId { self.id }
fn name(&self) -> &str { "my-daemon" }
async fn init(&mut self, _config: &DaemonConfig) -> duende_core::Result<()> {
Ok(())
}
async fn run(&mut self, ctx: &mut DaemonContext) -> duende_core::Result<ExitReason> {
while !ctx.should_shutdown() {
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
}
Ok(ExitReason::Graceful)
}
async fn shutdown(&mut self, _timeout: std::time::Duration) -> duende_core::Result<()> {
Ok(())
}
}
This crate follows Toyota Production System principles:
MIT OR Apache-2.0