pub trait DfeApp: Sized {
type Config: DeserializeOwned + Debug + Send + Sync;
// Required methods
fn name(&self) -> &str;
fn env_prefix(&self) -> &str;
fn version_info(&self) -> VersionInfo;
fn common_args(&self) -> &CommonArgs;
fn load_config(&self, path: Option<&str>) -> Result<Self::Config, CliError>;
fn run_service(
&self,
config: Self::Config,
runtime: ServiceRuntime,
) -> impl Future<Output = Result<(), CliError>> + Send;
// Provided methods
fn command(&self) -> Option<&StandardCommand> { ... }
fn scaling_components(
&self,
_config: &Self::Config,
) -> Vec<ScalingComponent> { ... }
fn register_metrics(&self, _manager: &MetricsManager) { ... }
fn deployment_contract(&self) -> Option<DeploymentContract> { ... }
}cli only.Expand description
Trait for DFE service applications.
Implement this trait to get the standard CLI lifecycle for free.
The 80% common behaviour (logging, config, metrics, version) is handled
by run_app(). Your app provides the 20% (config type, service logic).
Required Associated Types§
Required Methods§
Sourcefn env_prefix(&self) -> &str
fn env_prefix(&self) -> &str
Environment variable prefix for config cascade (e.g. “DFE_LOADER”).
Sourcefn version_info(&self) -> VersionInfo
fn version_info(&self) -> VersionInfo
Version information for this service.
Sourcefn common_args(&self) -> &CommonArgs
fn common_args(&self) -> &CommonArgs
Access the common CLI arguments.
Sourcefn load_config(&self, path: Option<&str>) -> Result<Self::Config, CliError>
fn load_config(&self, path: Option<&str>) -> Result<Self::Config, CliError>
Load application configuration from the given path (or defaults).
§Errors
Returns CliError if configuration cannot be loaded or parsed.
Sourcefn run_service(
&self,
config: Self::Config,
runtime: ServiceRuntime,
) -> impl Future<Output = Result<(), CliError>> + Send
fn run_service( &self, config: Self::Config, runtime: ServiceRuntime, ) -> impl Future<Output = Result<(), CliError>> + Send
Run the main service loop.
Called after logging, config, and ServiceRuntime
are initialised. The runtime contains all common infrastructure (metrics,
memory guard, shutdown token, worker pool, scaling pressure). Apps just
use it – no boilerplate needed.
§Errors
Returns CliError if the service encounters a fatal error.
Provided Methods§
Sourcefn command(&self) -> Option<&StandardCommand>
fn command(&self) -> Option<&StandardCommand>
Resolve the active subcommand.
Returns None to default to StandardCommand::Run.
Sourcefn scaling_components(&self, _config: &Self::Config) -> Vec<ScalingComponent>
Available on crate feature scaling only.
fn scaling_components(&self, _config: &Self::Config) -> Vec<ScalingComponent>
scaling only.Provide scaling pressure components for KEDA autoscaling.
Override to register app-specific scaling signals (buffer depth, consumer lag, error rate, etc.). The default returns an empty vec.
Sourcefn register_metrics(&self, _manager: &MetricsManager)
Available on crate features metrics or otel-metrics only.
fn register_metrics(&self, _manager: &MetricsManager)
metrics or otel-metrics only.Register all metrics for this service.
Called by metrics-manifest and generate-artefacts subcommands to
capture the full metric catalogue without starting the service.
The default implementation is a no-op. Override to register
DfeMetrics, metric groups, and app-specific metrics.
Sourcefn deployment_contract(&self) -> Option<DeploymentContract>
Available on crate feature deployment only.
fn deployment_contract(&self) -> Option<DeploymentContract>
deployment only.Build the deployment contract for this service.
Called by generate-artefacts to produce container specs, health
endpoints, KEDA config, and metrics manifest. The default returns
None. Override to provide a contract.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".