- add: logout grpc function

- add: logout packet handler
- add: connection state and service for storing connection data
- add: session service calls to auth-service
- fix: compile error on database service due to moved redis cache
This commit is contained in:
2024-12-20 14:46:00 -05:00
parent 3c1f8c40d6
commit 18afa71d74
22 changed files with 265 additions and 46 deletions

View File

@@ -1,19 +1,18 @@
use auth_service::auth::auth_service_server::AuthServiceServer;
use auth_service::database_client::DatabaseClient;
use auth_service::database_client::DatabaseClientTrait;
use auth_service::session::session_service_client::SessionServiceClient;
use auth_service::grpc::MyAuthService;
use dotenv::dotenv;
use std::collections::HashMap;
use std::env;
use std::net::ToSocketAddrs;
use std::str::FromStr;
use std::sync::Arc;
use tokio::{select, signal};
use tonic::transport::Server;
use tracing::log::debug;
use tracing::{info, Level};
use utils::consul_registration;
use utils::service_discovery::get_service_address;
use warp::Filter;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -36,6 +35,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let health_check_url = format!("http://{}:{}/health", service_address, health_port);
let health_check_endpoint_addr = format!("{}:{}", service_address, health_port);
let db_nodes = get_service_address(&consul_url, "database-service").await?;
let session_nodes = get_service_address(&consul_url, "session-service").await?;
// Register service with Consul
let service_id = consul_registration::get_or_generate_service_id();
@@ -58,12 +58,17 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let db_address = db_nodes.get(0).unwrap();
let db_url = format!("http://{}:{}", db_address.ServiceAddress, db_address.ServicePort);
let database_client = DatabaseClient::connect(&db_url).await?;
let db_client = Arc::new(DatabaseClient::connect(&db_url).await?);
let session_address = session_nodes.get(0).unwrap();
let session_address = format!("http://{}:{}", session_address.ServiceAddress, session_address.ServicePort);
let session_client = Arc::new(SessionServiceClient::connect(session_address).await?);
let full_addr = format!("{}:{}", &addr, port);
let address = full_addr.parse().expect("Invalid address");
let auth_service = MyAuthService {
db_client: database_client,
db_client,
session_client
};
println!("Authentication Service running on {}", addr);