soph_core/traits/
application.rs1use crate::{support::Container, traits::ServiceTrait, Result};
2use async_trait::async_trait;
3
4#[async_trait]
5pub trait ApplicationTrait: 'static {
6 type Service: ServiceTrait;
7
8 #[cfg(feature = "migration")]
9 type Migrator: sea_orm_migration::MigratorTrait;
10
11 #[cfg(feature = "server")]
12 fn with_routing() -> impl ServiceTrait;
13
14 #[cfg(feature = "schedule")]
15 fn with_schedule() -> impl ServiceTrait;
16
17 #[cfg(feature = "console")]
18 fn with_console() -> impl ServiceTrait;
19
20 #[cfg(feature = "worker")]
21 fn with_worker() -> impl ServiceTrait;
22
23 fn configure() -> Result<()> {
24 #[cfg(not(feature = "tracing"))]
25 {
26 use tracing_subscriber::layer::SubscriberExt;
27
28 let subscriber = tracing_subscriber::registry().with(tracing_subscriber::fmt::layer().with_target(false));
29 let _ = tracing::subscriber::set_global_default(subscriber);
30 }
31
32 #[cfg(feature = "color-eyre")]
33 color_eyre::install()?;
34
35 Ok(())
36 }
37
38 async fn register(container: Container) -> Result<Container> {
39 Ok(container)
40 }
41
42 async fn boot() {}
43}