websocket for single db update
This commit is contained in:
@@ -5,19 +5,18 @@ use r2d2_sqlite::SqliteConnectionManager;
|
||||
use tokio::sync::mpsc;
|
||||
use axum::extract::{ws::{Message, WebSocket, WebSocketUpgrade}, State};
|
||||
|
||||
use crate::utils::websocket::WsMap;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AppState {
|
||||
pub hotel_pools: HotelPool,
|
||||
pub logs_pool: Pool<SqliteConnectionManager>,
|
||||
pub ws_map: WsMap,
|
||||
}
|
||||
|
||||
|
||||
type HotelId = i32; // or i32 if you want numeric ids
|
||||
|
||||
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AppState {
|
||||
pub hotel_pools: HotelPool,
|
||||
pub logs_pool: Pool<SqliteConnectionManager>,
|
||||
pub ws_map: WsMap,
|
||||
|
||||
}
|
||||
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct HotelPool {
|
||||
hotel_pools: Arc<DashMap<HotelId, Pool<SqliteConnectionManager>>>,
|
||||
|
||||
@@ -12,11 +12,11 @@ use crate::utils::{auth::AuthClaims, db_pool::{AppState, HotelPool}};
|
||||
|
||||
|
||||
/// Type alias: user_id → sender to that user
|
||||
type UserMap = DashMap<i32, mpsc::UnboundedSender<Message>>;
|
||||
pub type UserMap = DashMap<i32, mpsc::UnboundedSender<Message>>;
|
||||
/// hotel_id → users
|
||||
type HotelMap = DashMap<i32, Arc<UserMap>>;
|
||||
pub type HotelMap = DashMap<i32, Arc<UserMap>>;
|
||||
/// global map of all hotels
|
||||
type WsMap = Arc<HotelMap>;
|
||||
pub type WsMap = Arc<HotelMap>;
|
||||
/// Type alias: user_id → sender to that user
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user