-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added MetadataService with GetHealth and GetVersion (#267)
Added an additional service. "MetadataService" for admin functionality that does not touch DCS itself. GetHealth => for getting the gRPC server status GetVersion => for getting the version of the cargo package. Nothing too fancy, but can be handy for the client and verification. Co-authored-by: dutchie032 <dutchie032>
- Loading branch information
1 parent
36a187d
commit 64d5dc3
Showing
8 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
syntax = "proto3"; | ||
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/meta data like server health checks and version | ||
service MetadataService { | ||
|
||
rpc GetHealth(GetHealthRequest) returns (GetHealthResponse) {} | ||
|
||
rpc GetVersion(GetVersionRequest) returns (GetVersionResponse) {} | ||
} | ||
|
||
message GetHealthRequest { | ||
} | ||
|
||
message GetHealthResponse { | ||
bool alive = 1; | ||
} | ||
|
||
message GetVersionRequest { | ||
} | ||
|
||
message GetVersionResponse { | ||
string version = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ mod controller; | |
mod custom; | ||
mod group; | ||
mod hook; | ||
mod metadata; | ||
mod mission; | ||
mod net; | ||
mod srs; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<metadata::v0::GetHealthRequest>, | ||
) -> Result<Response<metadata::v0::GetHealthResponse>, Status> { | ||
let alive: bool = true; | ||
return Ok(Response::new(metadata::v0::GetHealthResponse { alive })); | ||
} | ||
|
||
async fn get_version( | ||
&self, | ||
_request: Request<metadata::v0::GetVersionRequest>, | ||
) -> Result<Response<metadata::v0::GetVersionResponse>, 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 })); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub mod v0 { | ||
tonic::include_proto!("dcs.metadata.v0"); | ||
} |