add: move database drivers to oiseau

This commit is contained in:
trisua 2025-06-08 14:15:42 -04:00
parent 40fce4bc77
commit 81036e3733
57 changed files with 638 additions and 1106 deletions

View file

@ -190,7 +190,7 @@ pub async fn handle_socket(socket: WebSocket, db: DataManager, community_id: Str
let channel_id_c = channel_id.clone();
let mut redis_task = tokio::spawn(async move {
// forward messages from redis to the socket
let mut pubsub = dbc.2.client.get_async_pubsub().await.unwrap();
let mut pubsub = dbc.0.1.client.get_async_pubsub().await.unwrap();
pubsub.subscribe(user.id).await.unwrap();
pubsub.subscribe(channel_id_c).await.unwrap();
@ -239,7 +239,7 @@ pub async fn handle_socket(socket: WebSocket, db: DataManager, community_id: Str
}
});
let db2c = db.2.clone();
let db2c = db.0.1.clone();
let heartbeat_task = tokio::spawn(async move {
let mut con = db2c.get_con().await;
let mut heartbeat = tokio::time::interval(Duration::from_secs(10));
@ -259,7 +259,9 @@ pub async fn handle_socket(socket: WebSocket, db: DataManager, community_id: Str
}
});
db.2.incr("atto.active_connections:chats".to_string()).await;
db.0.1
.incr("atto.active_connections:chats".to_string())
.await;
tokio::select! {
_ = (&mut recv_task) => redis_task.abort(),
@ -267,7 +269,9 @@ pub async fn handle_socket(socket: WebSocket, db: DataManager, community_id: Str
}
heartbeat_task.abort(); // kill
db.2.decr("atto.active_connections:chats".to_string()).await;
db.0.1
.decr("atto.active_connections:chats".to_string())
.await;
tracing::info!("socket terminate");
}