How loft-games/service-daemon-rs works
Service Daemon is a Tokio framework for declaring and supervising long-running services, injecting typed providers, and dispatching event-driven triggers. The principal workflow is: application declarations are expanded into link-time registries, the daemon resolves providers and prepares runtimes, then starts services under scheduling and restart policies; trigger handlers run through a separate dispatch lifecycle. Supporting branches cover managed state and recovery, logging, diagnostics/topology export, and simulation. The tree and README establish these capabilities; sampled source confirms startup orchestration and logging behavior, while some subsystem wiring is documented rather than directly sampled.
Main entry points: startup_pipeline.rs Startup Pipeline · mod.rs Service Runner · service.rs Link-Time Registries · services.rs Logging Services
Components 24
Declarations
- Service Macro
service-daemon-macro/src/service/mod.rs - Provider Macro
service-daemon-macro/src/provider/mod.rs - Trigger Macro
service-daemon-macro/src/trigger/mod.rs - Link-Time Registries
service-daemon/src/models/service.rs
Daemon Lifecycle
- Daemon Builder And API
service-daemon/src/core/service_daemon/builder.rs - Startup Pipeline
service-daemon/src/core/service_daemon/startup_pipeline.rs - Startup Preflight
service-daemon/src/core/service_daemon/startup_preflight.rs - Provider Resolution
service-daemon/src/core/service_daemon/provider_graph.rs - Provider Initialization
service-daemon/src/core/provider_init.rs - Service Runner
service-daemon/src/core/service_daemon/runner/mod.rs - Restart Supervisor
service-daemon/src/core/service_daemon/runner/supervisor.rs - Priority Waves
service-daemon/src/core/service_daemon/runner/wave.rs - Adaptive Scheduling
service-daemon/src/core/adaptive_scheduling.rs
Triggers And State
- Trigger Runner
service-daemon/src/core/trigger_runner/mod.rs - Trigger Dispatch
service-daemon/src/core/trigger_runner/dispatch.rs - Managed State
service-daemon/src/core/managed_state.rs - Service Context
service-daemon/src/core/context/mod.rs
Operations
- Logging Services
service-daemon/src/core/logging/services.rs - Log Event Queue
service-daemon/src/core/logging/model.rs - Diagnostics Store
service-daemon/src/core/diagnostics.rs - Topology Export
service-daemon/src/core/topology_collector.rs - Mock Simulation
service-daemon/src/core/context/simulation.rs
Other components
- Tokio Application
- Standard Error
Connections 22
- Tokio Application → Service Macro: declares services
- Tokio Application → Provider Macro: declares providers
- Tokio Application → Trigger Macro: declares triggers
- Service Macro → Link-Time Registries: generates entries
- Provider Macro → Link-Time Registries: generates entries
- Trigger Macro → Link-Time Registries: generates entries
- Tokio Application → Daemon Builder And API: builds and runs
- Daemon Builder And API → Startup Pipeline: starts lifecycle
- Startup Pipeline → Startup Preflight: runs checks
- Startup Preflight → Provider Resolution: prepares graph
- Provider Resolution → Provider Initialization: initializes providers
- Startup Pipeline → Service Runner: spawns services
- Service Runner → Restart Supervisor: supervises generations
- Service Runner → Priority Waves: orders startup
- Service Runner → Adaptive Scheduling: selects runtime lanes
- Trigger Runner → Trigger Dispatch: dispatches payloads
- Service Context → Managed State: accesses state
- Logging Services → Log Event Queue: consumes events
- Logging Services → Standard Error: writes console output
- Startup Pipeline → Diagnostics Store: records runtime observations
- Startup Pipeline → Topology Export: starts collector
- Tokio Application → Mock Simulation: simulates async behavior