- add: Character service can now actually create a character correctly in the database
- add: character db client to allow the character service to talk to the database service - update: character.proto to make character data shared
This commit is contained in:
@@ -1,13 +1,19 @@
|
||||
mod character_service;
|
||||
mod character_db_client;
|
||||
pub mod database {
|
||||
tonic::include_proto!("character_db_api");
|
||||
}
|
||||
|
||||
use dotenv::dotenv;
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
use tokio::{select, signal};
|
||||
use tracing::{info, Level};
|
||||
use utils::consul_registration;
|
||||
use utils::service_discovery::get_service_address;
|
||||
use crate::character_db_client::CharacterDbClient;
|
||||
use crate::character_service::character::character_service_server::CharacterServiceServer;
|
||||
use crate::character_service::MyCharacterService;
|
||||
|
||||
@@ -55,7 +61,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let address = full_addr.parse().expect("Invalid address");
|
||||
let db_address = db_nodes.get(0).unwrap();
|
||||
let db_url = format!("http://{}:{}", db_address.ServiceAddress, db_address.ServicePort);
|
||||
let character_service = MyCharacterService::default();
|
||||
let character_db_client = Arc::new(CharacterDbClient::connect(&db_url).await?);
|
||||
let character_service = MyCharacterService {
|
||||
character_db_client
|
||||
};
|
||||
|
||||
tonic::transport::Server::builder()
|
||||
.add_service(CharacterServiceServer::new(character_service))
|
||||
|
||||
Reference in New Issue
Block a user