Ready to implement sync thread logic

This commit is contained in:
2025-11-18 22:17:39 +01:00
parent 5c13cffe08
commit c9b703bea3
9 changed files with 126 additions and 2 deletions

View File

@@ -0,0 +1,32 @@
//! # Matrix sync thread
//!
//! This file contains the logic performed by the threads that synchronize with Matrix account.
use crate::broadcast_messages::BroadcastSender;
use crate::matrix_connection::matrix_client::MatrixClient;
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct MatrixSyncTaskID(uuid::Uuid);
/// Start synchronization thread for a given user
pub async fn start_sync_thread(
client: MatrixClient,
tx: BroadcastSender,
) -> anyhow::Result<MatrixSyncTaskID> {
let task_id = MatrixSyncTaskID(uuid::Uuid::new_v4());
let task_id_clone = task_id.clone();
tokio::task::spawn(async move {
sync_thread_task(task_id_clone, client, tx).await;
});
Ok(task_id)
}
/// Sync thread function for a single function
async fn sync_thread_task(task_id: MatrixSyncTaskID, client: MatrixClient, _tx: BroadcastSender) {
loop {
println!("TODO : sync actions {task_id:?} {:?}", client.email);
tokio::time::sleep(std::time::Duration::from_millis(1000)).await;
}
}