From eff3537198ef40c1ff2ca27bcab72c22557bf9dc Mon Sep 17 00:00:00 2001 From: dutchie032 Date: Tue, 24 Sep 2024 19:12:31 +0200 Subject: [PATCH] updated administration service to metadataservice --- protos/dcs/dcs.proto | 2 +- .../v0/metadata.proto} | 10 +++---- src/rpc.rs | 2 +- src/rpc/administration.rs | 30 ------------------- src/rpc/metadata.rs | 26 ++++++++++++++++ src/server.rs | 4 +-- stubs/src/administration.rs | 3 -- stubs/src/lib.rs | 2 +- stubs/src/metadata.rs | 3 ++ 9 files changed, 39 insertions(+), 43 deletions(-) rename protos/dcs/{administration/v0/administration.proto => metadata/v0/metadata.proto} (54%) delete mode 100644 src/rpc/administration.rs create mode 100644 src/rpc/metadata.rs delete mode 100644 stubs/src/administration.rs create mode 100644 stubs/src/metadata.rs diff --git a/protos/dcs/dcs.proto b/protos/dcs/dcs.proto index 5d949f4..293d322 100644 --- a/protos/dcs/dcs.proto +++ b/protos/dcs/dcs.proto @@ -2,7 +2,6 @@ syntax = "proto3"; package dcs; -import "dcs/administration/v0/administration.proto"; import "dcs/atmosphere/v0/atmosphere.proto"; import "dcs/coalition/v0/coalition.proto"; import "dcs/common/v0/common.proto"; @@ -10,6 +9,7 @@ import "dcs/controller/v0/controller.proto"; import "dcs/custom/v0/custom.proto"; import "dcs/group/v0/group.proto"; import "dcs/hook/v0/hook.proto"; +import "dcs/metadata/v0/metadata.proto"; import "dcs/mission/v0/mission.proto"; import "dcs/net/v0/net.proto"; import "dcs/srs/v0/srs.proto"; diff --git a/protos/dcs/administration/v0/administration.proto b/protos/dcs/metadata/v0/metadata.proto similarity index 54% rename from protos/dcs/administration/v0/administration.proto rename to protos/dcs/metadata/v0/metadata.proto index 6dc124d..938d4ce 100644 --- a/protos/dcs/administration/v0/administration.proto +++ b/protos/dcs/metadata/v0/metadata.proto @@ -1,10 +1,10 @@ syntax = "proto3"; -package dcs.administration.v0; -option csharp_namespace = "RurouniJones.Dcs.Grpc.V0.Administration"; -option go_package = "github.com/DCS-gRPC/go-bindings/dcs/v0/administration"; +package dcs.metadata.v0; +option csharp_namespace = "RurouniJones.Dcs.Grpc.V0.Metadata"; +option go_package = "github.com/DCS-gRPC/go-bindings/dcs/v0/metadata"; -//A service to get administrative data like health and version -service AdministrationService { +//A service to get administrative/meta data like server health checks and version +service MetadataService { rpc GetHealth(GetHealthRequest) returns (GetHealthResponse) {} diff --git a/src/rpc.rs b/src/rpc.rs index 6856fee..499c005 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -10,13 +10,13 @@ pub use self::srs::Srs; use crate::shutdown::ShutdownHandle; use crate::stats::Stats; -mod administration; mod atmosphere; mod coalition; mod controller; mod custom; mod group; mod hook; +mod metadata; mod mission; mod net; mod srs; diff --git a/src/rpc/administration.rs b/src/rpc/administration.rs deleted file mode 100644 index c4dce30..0000000 --- a/src/rpc/administration.rs +++ /dev/null @@ -1,30 +0,0 @@ -use stubs::administration::v0::administration_service_server::AdministrationService; -use stubs::*; -use tonic::async_trait; -use tonic::{Request, Response, Status}; - -use super::MissionRpc; - -#[async_trait] -impl AdministrationService for MissionRpc { - async fn get_health( - &self, - _request: Request, - ) -> Result, Status> { - let alive: bool = true; - return Ok(Response::new(administration::v0::GetHealthResponse { - alive, - })); - } - - async fn get_version( - &self, - _request: Request, - ) -> Result, Status> { - const VERSION: Option<&str> = option_env!("CARGO_PKG_VERSION"); - let version = VERSION.unwrap_or("unknown").to_string(); - return Ok(Response::new(administration::v0::GetVersionResponse { - version, - })); - } -} diff --git a/src/rpc/metadata.rs b/src/rpc/metadata.rs new file mode 100644 index 0000000..415c82d --- /dev/null +++ b/src/rpc/metadata.rs @@ -0,0 +1,26 @@ +use stubs::metadata::v0::metadata_service_server::MetadataService; +use stubs::*; +use tonic::async_trait; +use tonic::{Request, Response, Status}; + +use super::MissionRpc; + +#[async_trait] +impl MetadataService for MissionRpc { + async fn get_health( + &self, + _request: Request, + ) -> Result, Status> { + let alive: bool = true; + return Ok(Response::new(metadata::v0::GetHealthResponse { alive })); + } + + async fn get_version( + &self, + _request: Request, + ) -> Result, Status> { + const VERSION: Option<&str> = option_env!("CARGO_PKG_VERSION"); + let version = VERSION.unwrap_or("unknown").to_string(); + return Ok(Response::new(metadata::v0::GetVersionResponse { version })); + } +} diff --git a/src/server.rs b/src/server.rs index eea5d82..4bcd761 100644 --- a/src/server.rs +++ b/src/server.rs @@ -5,13 +5,13 @@ use std::time::Duration; use dcs_module_ipc::IPC; use futures_util::FutureExt; -use stubs::administration::v0::administration_service_server::AdministrationServiceServer; use stubs::atmosphere::v0::atmosphere_service_server::AtmosphereServiceServer; use stubs::coalition::v0::coalition_service_server::CoalitionServiceServer; use stubs::controller::v0::controller_service_server::ControllerServiceServer; use stubs::custom::v0::custom_service_server::CustomServiceServer; use stubs::group::v0::group_service_server::GroupServiceServer; use stubs::hook::v0::hook_service_server::HookServiceServer; +use stubs::metadata::v0::metadata_service_server::MetadataServiceServer; use stubs::mission::v0::mission_service_server::MissionServiceServer; use stubs::mission::v0::StreamEventsResponse; use stubs::net::v0::net_service_server::NetServiceServer; @@ -244,13 +244,13 @@ async fn try_run( }); transport::Server::builder() - .add_service(AdministrationServiceServer::new(mission_rpc.clone())) .add_service(AtmosphereServiceServer::new(mission_rpc.clone())) .add_service(CoalitionServiceServer::new(mission_rpc.clone())) .add_service(ControllerServiceServer::new(mission_rpc.clone())) .add_service(CustomServiceServer::new(mission_rpc.clone())) .add_service(GroupServiceServer::new(mission_rpc.clone())) .add_service(HookServiceServer::new(hook_rpc)) + .add_service(MetadataServiceServer::new(mission_rpc.clone())) .add_service(MissionServiceServer::new(mission_rpc.clone())) .add_service(NetServiceServer::new(mission_rpc.clone())) .add_service(TimerServiceServer::new(mission_rpc.clone())) diff --git a/stubs/src/administration.rs b/stubs/src/administration.rs deleted file mode 100644 index 06b58de..0000000 --- a/stubs/src/administration.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod v0 { - tonic::include_proto!("dcs.administration.v0"); -} diff --git a/stubs/src/lib.rs b/stubs/src/lib.rs index ad71dc8..9b107bf 100644 --- a/stubs/src/lib.rs +++ b/stubs/src/lib.rs @@ -3,7 +3,6 @@ #![allow(clippy::derive_partial_eq_without_eq)] #![allow(clippy::large_enum_variant)] -pub mod administration; pub mod atmosphere; pub mod coalition; pub mod common; @@ -11,6 +10,7 @@ pub mod controller; pub mod custom; pub mod group; pub mod hook; +pub mod metadata; pub mod mission; pub mod net; pub mod srs; diff --git a/stubs/src/metadata.rs b/stubs/src/metadata.rs new file mode 100644 index 0000000..3e83a46 --- /dev/null +++ b/stubs/src/metadata.rs @@ -0,0 +1,3 @@ +pub mod v0 { + tonic::include_proto!("dcs.metadata.v0"); +}