More work.
Added chat service Updated packet service to pass the tcp stream around in a Arc type. Updated character position data to not require multiplying the coords Added more debug logs Added an interceptor for gRPC comms with the chat server Updated build and push script for the chat server changes
This commit is contained in:
@@ -21,6 +21,7 @@ serde_json = "1.0.133"
|
||||
async-trait = "0.1.83"
|
||||
utils = { path = "../utils" }
|
||||
tonic-health = "0.12.3"
|
||||
log = "0.4.26"
|
||||
|
||||
[build-dependencies]
|
||||
tonic-build = "0.12.3"
|
||||
|
||||
@@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||
use sqlx::{FromRow, Row};
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::Mutex;
|
||||
use tracing::debug;
|
||||
use log::debug;
|
||||
use utils::redis_cache::{Cache, RedisCache};
|
||||
|
||||
#[derive(Debug, FromRow, Serialize, Deserialize)]
|
||||
@@ -24,6 +24,8 @@ impl SessionRepository {
|
||||
pub async fn get_session(&self, session_id: &str) -> Result<Session, sqlx::Error> {
|
||||
let cache_key = format!("session:{}", session_id);
|
||||
|
||||
debug!("get_session: {:?}", session_id);
|
||||
|
||||
if let Some(session) = self
|
||||
.cache
|
||||
.lock()
|
||||
@@ -32,10 +34,13 @@ impl SessionRepository {
|
||||
.await
|
||||
.map_err(|_| sqlx::Error::RowNotFound)?
|
||||
{
|
||||
debug!("Found session in cache: {:?}", session);
|
||||
return Ok(session);
|
||||
}
|
||||
|
||||
// Fetch from database
|
||||
debug!("Session not found in cache, fetching from database");
|
||||
|
||||
// Fetch from the database
|
||||
let session = sqlx::query_as::<_, Session>("SELECT id, \"userId\" as user_id FROM session WHERE id = $1")
|
||||
.bind(session_id)
|
||||
.fetch_one(&self.pool)
|
||||
|
||||
Reference in New Issue
Block a user