sinan 0.1.0

A Boilerplate for Rapid Axum Web Service Deployment.
Documentation
use std::any::{Any, type_name};

use crate::contracts::Application;

pub trait Service: Any + Send + Sync {
    fn register<A: Application + ?Sized>() -> Self
    where
        Self: Sized;

    fn boot<A: Application + ?Sized>() -> eyre::Result<()>
    where
        Self: Sized,
    {
        tracing::info!("[service] {} booted", type_name::<Self>());

        Ok(())
    }
}

// register 核心基础服务,服务之间无依赖;同步操作;可以通过 container 调取已注册服务
// register 只依赖 Application 上下文
// boot 依赖基础服务;可异步操作;可以通过全局 container 调取已注册服务,参数获取当前服务
// boot 阶段需要注册的服务肯定都已经注册好了,比如 tracing