reactive_graph_instance_system_impl/
instance_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_instance_system_api::EntityInstanceImportExportManager;
8use reactive_graph_instance_system_api::InstanceSystem;
9use reactive_graph_instance_system_api::RelationInstanceImportExportManager;
10use reactive_graph_lifecycle::Lifecycle;
11use reactive_graph_reactive_service_api::ReactiveSystem;
12
13#[derive(Component)]
14pub struct InstanceSystemImpl {
15 entity_instance_import_export_manager: Arc<dyn EntityInstanceImportExportManager + Send + Sync>,
16 relation_instance_import_export_manager: Arc<dyn RelationInstanceImportExportManager + Send + Sync>,
17
18 reactive_system: Arc<dyn ReactiveSystem + Send + Sync>,
19}
20
21#[async_trait]
22#[component_alias]
23impl InstanceSystem for InstanceSystemImpl {
24 fn get_entity_instance_import_export_manager(&self) -> Arc<dyn EntityInstanceImportExportManager + Send + Sync> {
25 self.entity_instance_import_export_manager.clone()
26 }
27
28 fn get_relation_instance_import_export_manager(&self) -> Arc<dyn RelationInstanceImportExportManager + Send + Sync> {
29 self.relation_instance_import_export_manager.clone()
30 }
31
32 fn reactive_system(&self) -> Arc<dyn ReactiveSystem + Send + Sync> {
33 self.reactive_system.clone()
34 }
35}
36
37#[async_trait]
38impl Lifecycle for InstanceSystemImpl {
39 async fn init(&self) {
40 self.entity_instance_import_export_manager.init().await;
41 self.relation_instance_import_export_manager.init().await;
42 }
43
44 async fn post_init(&self) {
45 self.entity_instance_import_export_manager.post_init().await;
46 self.relation_instance_import_export_manager.post_init().await;
47 }
48
49 async fn pre_shutdown(&self) {
50 self.relation_instance_import_export_manager.pre_shutdown().await;
51 self.entity_instance_import_export_manager.pre_shutdown().await;
52 }
53
54 async fn shutdown(&self) {
55 self.relation_instance_import_export_manager.shutdown().await;
56 self.entity_instance_import_export_manager.shutdown().await;
57 }
58}