- add: handle channel list request

- add: handle server select request
- add: handle character list request stub
- add: start health check function for consul
This commit is contained in:
2024-12-13 04:40:07 -05:00
parent 1220d7a031
commit 38ea2ddb71
9 changed files with 133 additions and 49 deletions

View File

@@ -1,23 +1,23 @@
use crate::auth_client::AuthClient;
use crate::bufferpool::BufferPool;
use crate::metrics::{ACTIVE_CONNECTIONS, PACKETS_RECEIVED};
use crate::packet::Packet;
use dotenv::dotenv;
use std::collections::HashMap;
use std::env;
use std::error::Error;
use std::net::ToSocketAddrs;
use std::str::FromStr;
use std::sync::Arc;
use dotenv::dotenv;
use tokio::io::AsyncReadExt;
use tokio::net::{TcpListener, TcpStream};
use tokio::io::{AsyncReadExt};
use tokio::{select, signal};
use tokio::sync::{Mutex, Semaphore};
use tracing::{info, error, debug, warn};
use tokio::{select, signal};
use tracing::Level;
use tracing::{debug, error, info, warn};
use utils::consul_registration;
use utils::service_discovery::get_service_address;
use warp::Filter;
use crate::auth_client::AuthClient;
use crate::bufferpool::BufferPool;
use crate::metrics::{ACTIVE_CONNECTIONS, PACKETS_RECEIVED};
use crate::packet::Packet;
mod packet_type;
mod packet;
@@ -88,7 +88,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let service_id = consul_registration::generate_service_id();
let tags = vec!["version-1.0".to_string()];
let mut meta = HashMap::new();
meta.insert("name".to_string(), "Athena".to_string());
consul_registration::register_service(
&consul_url,
service_id.as_str(),
@@ -102,17 +101,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.await?;
// Start health-check endpoint
let health_route = warp::path!("health")
.map(|| warp::reply::with_status("OK", warp::http::StatusCode::OK));
tokio::spawn(warp::serve(health_route).run(health_check_endpoint_addr.to_socket_addrs()?.next().unwrap()));
consul_registration::start_health_check(addr.as_str()).await?;
let auth_address = auth_node.get(0).unwrap();
let auth_url = format!("http://{}:{}", auth_address.ServiceAddress, auth_address.ServicePort);
let auth_client = Arc::new(Mutex::new(AuthClient::connect(&auth_url).await?));
let full_addr = format!("{}:{}", &addr, port);
// let address = full_addr.parse().expect("Invalid address");
tokio::spawn(async move {
let semaphore = Arc::new(Semaphore::new(MAX_CONCURRENT_CONNECTIONS));