- add: character service grpc server impl for getting the character list

This commit is contained in:
2024-12-27 18:58:45 -05:00
parent bdc2384f12
commit f99fda9e1a
2 changed files with 66 additions and 0 deletions

View File

@@ -1,3 +1,5 @@
mod character_service;
use dotenv::dotenv;
use std::collections::HashMap;
use std::env;
@@ -6,6 +8,8 @@ use tokio::{select, signal};
use tracing::{info, Level};
use utils::consul_registration;
use utils::service_discovery::get_service_address;
use crate::character_service::character::character_service_server::CharacterServiceServer;
use crate::character_service::MyCharacterService;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -47,8 +51,17 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Start health-check endpoint
consul_registration::start_health_check(addr.as_str()).await?;
let full_addr = format!("{}:{}", &addr, port);
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();
tonic::transport::Server::builder()
.add_service(CharacterServiceServer::new(character_service))
.serve(address)
.await?;
let mut sigterm_stream = signal::unix::signal(signal::unix::SignalKind::terminate())?;
select! {