reactive_graph_runtime_web_impl/
web_system_impl.rs

1use std::sync::Arc;
2
3use async_trait::async_trait;
4use reactive_graph_config_api::ConfigSystem;
5use reactive_graph_dynamic_graph_api::DynamicGraphSystem;
6use reactive_graph_graphql_api::GraphQLSystem;
7use springtime_di::Component;
8use springtime_di::component_alias;
9
10use reactive_graph_lifecycle::Lifecycle;
11use reactive_graph_plugin_graphql_api::PluginGraphQLSystem;
12use reactive_graph_reactive_service_api::ReactiveSystem;
13use reactive_graph_runtime_graphql_api::RuntimeGraphQLSystem;
14use reactive_graph_runtime_web_api::GraphQLServer;
15use reactive_graph_runtime_web_api::WebResourceManager;
16use reactive_graph_runtime_web_api::WebSystem;
17use reactive_graph_type_system_api::TypeSystem;
18
19#[derive(Component)]
20pub struct WebSystemImpl {
21    graphql_server: Arc<dyn GraphQLServer + Send + Sync>,
22    web_resource_manager: Arc<dyn WebResourceManager + Send + Sync>,
23    type_system: Arc<dyn TypeSystem + Send + Sync>,
24    reactive_system: Arc<dyn ReactiveSystem + Send + Sync>,
25    config_system: Arc<dyn ConfigSystem + Send + Sync>,
26    runtime_graphql_system: Arc<dyn RuntimeGraphQLSystem + Send + Sync>,
27    plugin_graphql_system: Arc<dyn PluginGraphQLSystem + Send + Sync>,
28    graphql_system: Arc<dyn GraphQLSystem + Send + Sync>,
29    dynamic_graph_system: Arc<dyn DynamicGraphSystem + Send + Sync>,
30}
31
32#[async_trait]
33#[component_alias]
34impl WebSystem for WebSystemImpl {
35    fn get_graphql_server(&self) -> Arc<dyn GraphQLServer + Send + Sync> {
36        self.graphql_server.clone()
37    }
38
39    fn get_web_resource_manager(&self) -> Arc<dyn WebResourceManager + Send + Sync> {
40        self.web_resource_manager.clone()
41    }
42
43    fn type_system(&self) -> Arc<dyn TypeSystem + Send + Sync> {
44        self.type_system.clone()
45    }
46
47    fn reactive_system(&self) -> Arc<dyn ReactiveSystem + Send + Sync> {
48        self.reactive_system.clone()
49    }
50
51    fn config_system(&self) -> Arc<dyn ConfigSystem + Send + Sync> {
52        self.config_system.clone()
53    }
54
55    fn runtime_graphql_system(&self) -> Arc<dyn RuntimeGraphQLSystem + Send + Sync> {
56        self.runtime_graphql_system.clone()
57    }
58
59    fn plugin_graphql_system(&self) -> Arc<dyn PluginGraphQLSystem + Send + Sync> {
60        self.plugin_graphql_system.clone()
61    }
62
63    fn dynamic_graph_system(&self) -> Arc<dyn DynamicGraphSystem + Send + Sync> {
64        self.dynamic_graph_system.clone()
65    }
66
67    fn graphql_system(&self) -> Arc<dyn GraphQLSystem + Send + Sync> {
68        self.graphql_system.clone()
69    }
70}
71
72#[async_trait]
73impl Lifecycle for WebSystemImpl {
74    async fn init(&self) {
75        self.web_resource_manager.init().await;
76        self.graphql_server.init().await;
77    }
78
79    async fn post_init(&self) {
80        self.web_resource_manager.post_init().await;
81        self.graphql_server.post_init().await;
82    }
83
84    async fn pre_shutdown(&self) {
85        self.graphql_server.pre_shutdown().await;
86        self.web_resource_manager.pre_shutdown().await;
87    }
88
89    async fn shutdown(&self) {
90        self.graphql_server.shutdown().await;
91        self.web_resource_manager.shutdown().await;
92    }
93}