(tools, client, server) chore:Remove GeneralService
This commit is contained in:
@ -5,9 +5,7 @@ use tonic::transport::Server;
|
||||
use tonic_web::GrpcWebLayer;
|
||||
|
||||
use crate::protocol::game_service_server::GameServiceServer;
|
||||
use crate::protocol::general_service_server::GeneralServiceServer;
|
||||
use crate::services::game_service::GameServiceImpl;
|
||||
use crate::services::general_service::GeneralServiceImpl;
|
||||
|
||||
pub(crate) struct GrpcServer;
|
||||
|
||||
@ -15,14 +13,12 @@ impl GrpcServer {
|
||||
pub(crate) async fn init() {
|
||||
let addr = SocketAddr::new([127, 0, 0, 1].into(), 12345);
|
||||
|
||||
let general_service = GeneralServiceServer::new(GeneralServiceImpl);
|
||||
let game_service = GameServiceServer::new(GameServiceImpl);
|
||||
|
||||
task::spawn(async move {
|
||||
Server::builder()
|
||||
.accept_http1(true)
|
||||
.layer(GrpcWebLayer::new())
|
||||
.add_service(general_service)
|
||||
.add_service(game_service)
|
||||
.serve(addr)
|
||||
.await
|
||||
|
1
Server/src/services.rs
Normal file
1
Server/src/services.rs
Normal file
@ -0,0 +1 @@
|
||||
pub(crate) mod game_service;
|
@ -1,19 +0,0 @@
|
||||
use tonic::{Request, Response, Status};
|
||||
|
||||
use crate::protocol::general_service_server::GeneralService;
|
||||
use crate::protocol::{Empty, ServerInfo};
|
||||
|
||||
pub(crate) struct GeneralServiceImpl;
|
||||
|
||||
#[tonic::async_trait]
|
||||
impl GeneralService for GeneralServiceImpl {
|
||||
async fn get_server_info(
|
||||
&self,
|
||||
_request: Request<Empty>,
|
||||
) -> Result<Response<ServerInfo>, Status> {
|
||||
Ok(Response::new(ServerInfo {
|
||||
lang: "Rust".into(),
|
||||
ver: "0.1.0".into(),
|
||||
}))
|
||||
}
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
pub(crate) mod game_service;
|
||||
pub(crate) mod general_service;
|
Reference in New Issue
Block a user