diode-base
Application building blocks for the diode
dependency-injection framework: layered configuration, long-running daemons, a
CLI entry point, structured tracing and metrics, and dynamic configuration.
[]
= "0.2"
= "0.3"
What it provides
- Configuration -
Configloads and merges layered JSON. Declare a typed section with#[config_section("name")]and read it withconfig.get. - Daemons - the
Daemontrait,AddDaemonExt/AddDaemonServiceExtto register background tasks, andRunDaemonsExt::run_daemonsto run them concurrently with cooperative, token-based shutdown. - CLI - the
Commandtrait,AddCommandExt, andRunMainExt::run_main, which parses arguments, loads config, sets up tracing/metrics, builds the app, and dispatches a subcommand. Built-inserverruns every daemon;configprints the resolved configuration. - Observability -
TracingandMetricswire uptracingand OpenTelemetry (OTLP) exporters from thetracing/metricsconfig sections. - Dynamic configuration - watch config sources and react to changes at runtime (for example to change the tracing level live).
- Testing - the
testingmodule ships integration-test helpers such asFreePort.
Example
A worker service driven by configuration, wired as a daemon and started through the CLI entry point:
use ExitCode;
use Arc;
use Duration;
use ;
use ;
use ;
// A typed configuration section, read from the `worker` key of the config file.
// A background worker: a `Service` (built from the container, reading its
// config) that is also a `Daemon` (runs until shutdown).
async
Features
macros(default) - the#[config_section(..)]attribute macro.
License
Licensed under either of MIT or Apache-2.0 at your option.