reactive_graph_runtime_service_impl/
runtime_system_impl.rs1use std::sync::Arc;
2
3use async_trait::async_trait;
4use springtime_di::Component;
5use springtime_di::component_alias;
6
7use reactive_graph_lifecycle::Lifecycle;
8use reactive_graph_runtime_service_api::RuntimeSystem;
9use reactive_graph_runtime_service_api::ShutdownManager;
10use reactive_graph_runtime_service_api::runtime_type_system_registrator::RuntimeTypeSystemRegistrator;
11
12#[derive(Component)]
13pub struct RuntimeSystemImpl {
14 shutdown_manager: Arc<dyn ShutdownManager + Send + Sync>,
15 runtime_type_system_registrator: Arc<dyn RuntimeTypeSystemRegistrator + Send + Sync>,
16}
17
18#[async_trait]
19#[component_alias]
20impl RuntimeSystem for RuntimeSystemImpl {
21 fn get_shutdown_manager(&self) -> Arc<dyn ShutdownManager + Send + Sync> {
22 self.shutdown_manager.clone()
23 }
24}
25
26#[async_trait]
27impl Lifecycle for RuntimeSystemImpl {
28 async fn init(&self) {
29 self.runtime_type_system_registrator.init().await;
30 self.shutdown_manager.init().await;
31 }
32
33 async fn post_init(&self) {
34 self.runtime_type_system_registrator.post_init().await;
35 self.shutdown_manager.post_init().await;
36 }
37
38 async fn pre_shutdown(&self) {
39 self.shutdown_manager.pre_shutdown().await;
40 self.runtime_type_system_registrator.pre_shutdown().await;
41 }
42
43 async fn shutdown(&self) {
44 self.shutdown_manager.shutdown().await;
45 self.runtime_type_system_registrator.shutdown().await;
46 }
47}