Add comprehensive documentation and unit tests
Documentation: - Add detailed README files for all services (auth, character, database, launcher, packet, utils, world) - Create API documentation for the database service with detailed endpoint specifications - Document database schema and relationships - Add service architecture overviews and configuration instructions Unit Tests: - Implement comprehensive test suite for database repositories (user, character, session) - Add gRPC service tests for database interactions - Create tests for packet service components (bufferpool, connection, packets) - Add utility service tests (health check, logging, load balancer, redis cache, service discovery) - Implement auth service user tests - Add character service tests Code Structure: - Reorganize test files into a more consistent structure - Create a dedicated tests crate for integration testing - Add test helpers and mock implementations for easier testing
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
use crate::session::{session_service_client::SessionServiceClient, GetSessionRequest, GetSessionResponse, RefreshSessionRequest, RefreshSessionResponse};
|
||||
use crate::session::{
|
||||
session_service_client::SessionServiceClient, GetSessionRequest, GetSessionResponse, RefreshSessionRequest,
|
||||
RefreshSessionResponse,
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use chrono::{DateTime, Utc};
|
||||
use std::error::Error;
|
||||
use tonic::transport::Channel;
|
||||
|
||||
#[async_trait]
|
||||
pub trait SessionClientTrait: Sized {
|
||||
async fn connect(endpoint: &str) -> Result<Self, Box<dyn std::error::Error>>;
|
||||
async fn get_session(
|
||||
&mut self,
|
||||
session_id: String,
|
||||
) -> Result<GetSessionResponse, Box<dyn std::error::Error>>;
|
||||
async fn get_session(&mut self, session_id: String) -> Result<GetSessionResponse, Box<dyn std::error::Error>>;
|
||||
async fn refresh_session(
|
||||
&mut self,
|
||||
session_id: String,
|
||||
@@ -27,18 +26,14 @@ impl SessionClientTrait for SessionClient {
|
||||
let client = SessionServiceClient::connect(endpoint.to_string()).await?;
|
||||
Ok(Self { client })
|
||||
}
|
||||
|
||||
|
||||
async fn get_session(&mut self, session_id: String) -> Result<GetSessionResponse, Box<dyn Error>> {
|
||||
let request = tonic::Request::new(GetSessionRequest {
|
||||
session_id,
|
||||
});
|
||||
let request = tonic::Request::new(GetSessionRequest { session_id });
|
||||
let response = self.client.get_session(request).await?;
|
||||
Ok(response.into_inner())
|
||||
}
|
||||
async fn refresh_session(&mut self, session_id: String) -> Result<RefreshSessionResponse, Box<dyn Error>> {
|
||||
let request = tonic::Request::new(RefreshSessionRequest {
|
||||
session_id,
|
||||
});
|
||||
let request = tonic::Request::new(RefreshSessionRequest { session_id });
|
||||
let response = self.client.refresh_session(request).await?;
|
||||
Ok(response.into_inner())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user