reactive_graph_remotes_impl/
instance_service_impl.rs1use std::sync::Arc;
2
3use async_trait::async_trait;
4use chrono::Utc;
5use springtime_di::Component;
6use springtime_di::component_alias;
7
8use reactive_graph_config_api::ConfigManager;
9use reactive_graph_lifecycle::Lifecycle;
10use reactive_graph_plugin_api::PLUGIN_API_VERSION;
11use reactive_graph_remotes_api::InstanceService;
12use reactive_graph_remotes_model::InstanceInfo;
13
14pub static VERSION: &str = env!("CARGO_PKG_VERSION");
15pub static TARGET_TRIPLE: &str = env!("VERGEN_CARGO_TARGET_TRIPLE");
16pub static GIT_TAG: &str = env!("VERGEN_GIT_DESCRIBE");
17pub static GIT_COMMIT: &str = env!("VERGEN_GIT_SHA");
18pub static RUSTC_CHANNEL: &str = env!("VERGEN_RUSTC_CHANNEL");
19pub static RUSTC_VERSION: &str = env!("VERGEN_RUSTC_SEMVER");
20
21#[derive(Component)]
22pub struct InstanceServiceImpl {
23 config_manager: Arc<dyn ConfigManager + Send + Sync>,
24}
25
26#[async_trait]
27#[component_alias]
28impl InstanceService for InstanceServiceImpl {
29 fn get_instance_info(&self) -> InstanceInfo {
30 let instance_config = self.config_manager.get_instance_config();
31 let graphql_server_config = self.config_manager.get_graphql_server_config();
32 InstanceInfo {
33 name: instance_config.name,
34 description: instance_config.description,
35 address: graphql_server_config.address(),
36 version: String::from(VERSION),
37 git_commit: String::from(GIT_COMMIT),
38 git_tag: String::from(GIT_TAG),
39 rustc_channel: String::from(RUSTC_CHANNEL),
40 rustc_version: String::from(RUSTC_VERSION),
41 plugin_api_version: String::from(PLUGIN_API_VERSION),
42 last_seen: Utc::now(),
43 }
44 }
45}
46
47#[async_trait]
48impl Lifecycle for InstanceServiceImpl {}