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:
2025-04-09 13:29:38 -04:00
parent d47d5f44b1
commit a8755bd3de
85 changed files with 4218 additions and 764 deletions

View File

@@ -1,21 +1,22 @@
use crate::grpc::database_service::MyDatabaseService;
use crate::grpc::session_service_server::SessionService;
use crate::grpc::{GetSessionRequest, GetSessionResponse, RefreshSessionRequest, RefreshSessionResponse};
use tonic::{Request, Response, Status};
use tracing::debug;
use crate::grpc::{GetSessionRequest, GetSessionResponse, RefreshSessionRequest, RefreshSessionResponse};
#[tonic::async_trait]
impl SessionService for MyDatabaseService {
async fn get_session(
&self,
request: Request<GetSessionRequest>,
) -> Result<Response<GetSessionResponse>, Status> {
async fn get_session(&self, request: Request<GetSessionRequest>) -> Result<Response<GetSessionResponse>, Status> {
let req = request.into_inner();
debug!("get_session: {:?}", req);
let session = self.db.session_repo.get_session(&req.session_id).await
let session = self
.db
.session_repo
.get_session(&req.session_id)
.await
.map_err(|_| Status::not_found("Session not found"))?;
debug!("session: {:?}", session);
Ok(Response::new(GetSessionResponse {
session_id: session.id,
@@ -23,18 +24,23 @@ impl SessionService for MyDatabaseService {
}))
}
async fn refresh_session(&self, request: Request<RefreshSessionRequest>) -> Result<Response<RefreshSessionResponse>, Status> {
async fn refresh_session(
&self,
request: Request<RefreshSessionRequest>,
) -> Result<Response<RefreshSessionResponse>, Status> {
let req = request.into_inner();
debug!("get_session: {:?}", req);
let session = self.db.session_repo.refresh_session(&req.session_id).await
let session = self
.db
.session_repo
.refresh_session(&req.session_id)
.await
.map_err(|_| Status::not_found("Session not found"))?;
let valid = true;
debug!("session: {:?}", session);
Ok(Response::new(RefreshSessionResponse {
valid
}))
Ok(Response::new(RefreshSessionResponse { valid }))
}
}