Skip to main content

App

Trait App 

Source
pub trait App<AppEv: Send + Sync + 'static, AppMetric: Send + Sync + 'static> {
    type AppConfig: Config;
    type AppSecrets: Secrets;
    type Setup;

    // Required methods
    fn name(&self) -> &'static str;
    fn setup<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        wora: &'life1 Wora<AppEv, AppMetric>,
        exec: impl 'async_trait + AsyncExecutor<AppEv, AppMetric>,
        fs: impl 'async_trait + WFS + 'static,
        metrics: Sender<O11yEvent<AppMetric>>,
        is_first_boot: bool,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Setup, Box<dyn Error>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn main<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        wora: &'life1 mut Wora<AppEv, AppMetric>,
        exec: impl 'async_trait + AsyncExecutor<AppEv, AppMetric>,
        fs: impl 'async_trait + WFS + 'static,
        metrics: Sender<O11yEvent<AppMetric>>,
    ) -> Pin<Box<dyn Future<Output = MainRetryAction> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn end<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        wora: &'life1 Wora<AppEv, AppMetric>,
        exec: impl 'async_trait + AsyncExecutor<AppEv, AppMetric>,
        fs: impl 'async_trait + WFS + 'static,
        metrics: Sender<O11yEvent<AppMetric>>,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn allow_concurrent_executions(&self) -> bool { ... }
    fn configure<'life0, 'async_trait>(
        &'life0 mut self,
        _config: <Self::AppConfig as Config>::ConfigT,
    ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error>>> + Send + 'async_trait>>
       where Self: Send + 'async_trait,
             'life0: 'async_trait { ... }
    fn reload_config<'life0, 'async_trait>(
        &'life0 mut self,
        reload: ConfigReload<<Self::AppConfig as Config>::ConfigT>,
    ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error>>> + Send + 'async_trait>>
       where Self: Send + 'async_trait,
             'life0: 'async_trait { ... }
    fn reload_secrets<'life0, 'async_trait>(
        &'life0 mut self,
        _reload: SecretReload<<Self::AppSecrets as Secrets>::SecretT>,
    ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error>>> + Send + 'async_trait>>
       where Self: Send + 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Application lifecycle implemented by WORA workloads.

Runtime health and readiness supervision is driven through Wora::report_health, Wora::report_readiness, or a cloned RuntimeStatusHandle, not by polling an app callback.

Required Associated Types§

Source

type AppConfig: Config

Configuration parser for the app.

Source

type AppSecrets: Secrets

Secret parser for the app.

Source

type Setup

Setup artifact type returned by setup.

Required Methods§

Source

fn name(&self) -> &'static str

Stable application name used for directories, locks, and logging.

Source

fn setup<'life0, 'life1, 'async_trait>( &'life0 mut self, wora: &'life1 Wora<AppEv, AppMetric>, exec: impl 'async_trait + AsyncExecutor<AppEv, AppMetric>, fs: impl 'async_trait + WFS + 'static, metrics: Sender<O11yEvent<AppMetric>>, is_first_boot: bool, ) -> Pin<Box<dyn Future<Output = Result<Self::Setup, Box<dyn Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Initialize application state after executor setup and before main.

Source

fn main<'life0, 'life1, 'async_trait>( &'life0 mut self, wora: &'life1 mut Wora<AppEv, AppMetric>, exec: impl 'async_trait + AsyncExecutor<AppEv, AppMetric>, fs: impl 'async_trait + WFS + 'static, metrics: Sender<O11yEvent<AppMetric>>, ) -> Pin<Box<dyn Future<Output = MainRetryAction> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Run the primary application loop.

Source

fn end<'life0, 'life1, 'async_trait>( &'life0 mut self, wora: &'life1 Wora<AppEv, AppMetric>, exec: impl 'async_trait + AsyncExecutor<AppEv, AppMetric>, fs: impl 'async_trait + WFS + 'static, metrics: Sender<O11yEvent<AppMetric>>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Clean up application state after main returns.

Provided Methods§

Source

fn allow_concurrent_executions(&self) -> bool

Return whether multiple instances may run concurrently.

Source

fn configure<'life0, 'async_trait>( &'life0 mut self, _config: <Self::AppConfig as Config>::ConfigT, ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error>>> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait,

Apply an initially loaded application configuration.

For event-driven apps, runtime config reloads usually flow through reload_config instead of this hook directly.

Source

fn reload_config<'life0, 'async_trait>( &'life0 mut self, reload: ConfigReload<<Self::AppConfig as Config>::ConfigT>, ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error>>> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait,

Apply a typed configuration reload.

Source

fn reload_secrets<'life0, 'async_trait>( &'life0 mut self, _reload: SecretReload<<Self::AppSecrets as Secrets>::SecretT>, ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error>>> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait,

Apply a typed secret reload.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§