- removed: api-service
- removed: session-service - updated: moved health check out of consul registration - updated: get service info to pull the service from the default namespace for the service account - updated: the rest of the services to be able to handle the new database tables
This commit is contained in:
@@ -2,7 +2,7 @@ use std::collections::HashMap;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ConnectionState {
|
||||
pub user_id: Option<i32>,
|
||||
pub user_id: Option<String>,
|
||||
pub session_id: Option<String>,
|
||||
pub character_id: Option<i8>,
|
||||
pub character_list: Option<Vec<u32>>,
|
||||
|
||||
@@ -158,8 +158,9 @@ pub(crate) async fn handle_login_req(
|
||||
debug!("Successfully logged in");
|
||||
|
||||
if let Some(mut state) = connection_service.get_connection_mut(&connection_id) {
|
||||
state.user_id = Some(response.user_id.parse().unwrap());
|
||||
state.session_id = Some(response.session_id.parse().unwrap());
|
||||
debug!("Response: {:?}", response);
|
||||
state.user_id = Some(response.user_id);
|
||||
state.session_id = Some(response.session_id);
|
||||
}
|
||||
|
||||
let mut id = 0;
|
||||
@@ -204,6 +205,7 @@ pub(crate) async fn handle_login_req(
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
debug!("Error getting service info: {}", err);
|
||||
let data = SrvLoginReply {
|
||||
result: srv_login_reply::Result::Failed,
|
||||
right: 0,
|
||||
|
||||
@@ -71,7 +71,7 @@ pub(crate) async fn handle_char_list_req(
|
||||
let request = CliCharListReq::decode(packet.payload.as_slice());
|
||||
debug!("{:?}", request);
|
||||
|
||||
let mut user_id = 0;
|
||||
let mut user_id= "".to_string();
|
||||
let session_id;
|
||||
if let Some(mut state) = connection_service.get_connection(&connection_id) {
|
||||
user_id = state.user_id.expect("Missing user id in connection state");
|
||||
@@ -83,7 +83,7 @@ pub(crate) async fn handle_char_list_req(
|
||||
// query the character service for the character list for this user
|
||||
let mut character_client = character_client.lock().await;
|
||||
let character_list = character_client
|
||||
.get_character_list(&user_id.to_string())
|
||||
.get_character_list(&user_id)
|
||||
.await?;
|
||||
let mut characters = vec![];
|
||||
let mut character_id_list: Vec<u32> = Vec::new();
|
||||
@@ -141,7 +141,7 @@ pub(crate) async fn handle_create_char_req(
|
||||
let request = CliCreateCharReq::decode(packet.payload.as_slice())?;
|
||||
debug!("{:?}", request);
|
||||
|
||||
let mut user_id = 0;
|
||||
let mut user_id = "".to_string();
|
||||
let session_id;
|
||||
if let Some(mut state) = connection_service.get_connection(&connection_id) {
|
||||
user_id = state.user_id.expect("Missing user id in connection state");
|
||||
@@ -194,7 +194,7 @@ pub(crate) async fn handle_delete_char_req(
|
||||
let request = CliDeleteCharReq::decode(packet.payload.as_slice())?;
|
||||
debug!("{:?}", request);
|
||||
|
||||
let mut user_id = 0;
|
||||
let mut user_id = "".to_string();
|
||||
let session_id;
|
||||
let mut character_id_list: Vec<u32> = Vec::new();
|
||||
|
||||
@@ -243,10 +243,10 @@ pub(crate) async fn handle_select_char_req(
|
||||
let request = CliSelectCharReq::decode(packet.payload.as_slice())?;
|
||||
debug!("{:?}", request);
|
||||
|
||||
let mut user_id = 0;
|
||||
let mut user_id = "".to_string();
|
||||
let mut character_id_list: Vec<u32> = Vec::new();
|
||||
if let Some(mut state) = connection_service.get_connection_mut(&connection_id) {
|
||||
user_id = state.user_id.expect("Missing user id in connection state");
|
||||
user_id = state.user_id.clone().expect("Missing user id in connection state");
|
||||
character_id_list = state
|
||||
.character_list
|
||||
.clone()
|
||||
@@ -368,7 +368,7 @@ pub(crate) async fn handle_select_char_req(
|
||||
pat_cooldown_time: stats.pat_cooldown_time as u32,
|
||||
skills: skill_list,
|
||||
hotbar: hotbar_list,
|
||||
tag: user_id as u32,
|
||||
tag: 100,
|
||||
name,
|
||||
};
|
||||
debug!("{:?}", data);
|
||||
|
||||
@@ -26,7 +26,7 @@ pub(crate) async fn handle_change_map_req(
|
||||
let request = CliChangeMapReq::decode(packet.payload.as_slice())?;
|
||||
debug!("{:?}", request);
|
||||
|
||||
let mut user_id = 0;
|
||||
let mut user_id = "".to_string();
|
||||
let mut char_id = 0;
|
||||
let mut character_id_list: Vec<u32> = Vec::new();
|
||||
let session_id;
|
||||
|
||||
@@ -21,7 +21,7 @@ use tokio::{select, signal};
|
||||
use tracing::Level;
|
||||
use tracing::{debug, error, info, warn};
|
||||
use tracing_subscriber::EnvFilter;
|
||||
use utils::{consul_registration, logging};
|
||||
use utils::{health_check, logging};
|
||||
use utils::service_discovery::{get_kube_service_endpoints_by_dns};
|
||||
use warp::Filter;
|
||||
|
||||
@@ -60,7 +60,7 @@ const MAX_CONCURRENT_CONNECTIONS: usize = 100;
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
dotenv().ok();
|
||||
let app_name = env!("CARGO_PKG_NAME");
|
||||
logging::setup_logging(app_name);
|
||||
logging::setup_logging(app_name, &["packet_service", "health_check"]);
|
||||
|
||||
// Set the gRPC server address
|
||||
let addr = env::var("LISTEN_ADDR").unwrap_or_else(|_| "0.0.0.0".to_string());
|
||||
@@ -70,7 +70,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let character_url = format!("http://{}",get_kube_service_endpoints_by_dns("character-service","tcp","character-service").await?.get(0).unwrap());
|
||||
|
||||
// Start health-check endpoint
|
||||
consul_registration::start_health_check(addr.as_str()).await?;
|
||||
health_check::start_health_check(addr.as_str()).await?;
|
||||
|
||||
let auth_client = Arc::new(Mutex::new(AuthClient::connect(&auth_url).await?));
|
||||
let character_client = Arc::new(Mutex::new(CharacterClient::connect(&character_url).await?));
|
||||
|
||||
Reference in New Issue
Block a user