- update: major refactor of the database-service to make it easy to add newer api services

- add: character database api
This commit is contained in:
2024-12-17 01:58:18 -05:00
parent 267422adb4
commit 52455d6ffc
18 changed files with 378 additions and 180 deletions

View File

@@ -1,4 +1,4 @@
use crate::database::{database_service_client::DatabaseServiceClient, CreateUserRequest, CreateUserResponse, GetUserByEmailRequest, GetUserByUsernameRequest, GetUserRequest, GetUserResponse};
use crate::database::{user_service_client::UserServiceClient, CreateUserRequest, CreateUserResponse, GetUserByEmailRequest, GetUserByUsernameRequest, GetUserRequest, GetUserResponse};
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use std::error::Error;
@@ -18,7 +18,7 @@ pub trait DatabaseClientTrait: Sized {
}
#[derive(Clone)]
pub struct DatabaseClient {
client: DatabaseServiceClient<Channel>,
client: UserServiceClient<Channel>,
}
#[derive(Debug)]
@@ -31,7 +31,7 @@ pub struct PasswordReset {
#[async_trait]
impl DatabaseClientTrait for DatabaseClient {
async fn connect(endpoint: &str) -> Result<Self, Box<dyn std::error::Error>> {
let client = DatabaseServiceClient::connect(endpoint.to_string()).await?;
let client = UserServiceClient::connect(endpoint.to_string()).await?;
Ok(Self { client })
}

View File

@@ -7,7 +7,7 @@ pub mod auth {
tonic::include_proto!("auth"); // Path matches the package name in auth.proto
}
pub mod database {
tonic::include_proto!("database"); // Matches package name in database.proto
tonic::include_proto!("user_db_api"); // Matches package name in user_db_api.proto
}
#[cfg(test)]