- add: utils library
- add: packet-service to handle game client packets - fix: health check for database-service - fix: health check for auth-service
This commit is contained in:
24
packet-service/src/auth_client.rs
Normal file
24
packet-service/src/auth_client.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
use crate::auth::auth_service_client::AuthServiceClient;
|
||||
use crate::auth::{LoginRequest, LoginResponse};
|
||||
use tonic::transport::Channel;
|
||||
|
||||
pub struct AuthClient {
|
||||
client: AuthServiceClient<Channel>,
|
||||
}
|
||||
|
||||
impl AuthClient {
|
||||
pub async fn connect(endpoint: &str) -> Result<Self, Box<dyn std::error::Error>> {
|
||||
let client = AuthServiceClient::connect(endpoint.to_string()).await?;
|
||||
Ok(AuthClient { client })
|
||||
}
|
||||
|
||||
pub async fn login(&mut self, username: &str, password: &str) -> Result<LoginResponse, Box<dyn std::error::Error + Send + Sync>> {
|
||||
let request = LoginRequest {
|
||||
username: username.to_string(),
|
||||
password: password.to_string(),
|
||||
};
|
||||
|
||||
let response = self.client.login(request).await?;
|
||||
Ok(response.into_inner())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user