mirror of
https://github.com/Steffo99/todocolors.git
synced 2024-11-22 08:14:18 +00:00
Use u64
instead of Uuid
to match Redis behaviour
https://redis.io/commands/xadd/
This commit is contained in:
parent
3353eea1a0
commit
66c8ee9a79
2 changed files with 29 additions and 4 deletions
|
@ -17,4 +17,3 @@ redis = { version = "0.23.1", features = ["r2d2", "ahash", "cluster", "tokio-com
|
||||||
serde = { version = "1.0.178", features = ["derive"] }
|
serde = { version = "1.0.178", features = ["derive"] }
|
||||||
tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread"] }
|
tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread"] }
|
||||||
tower-http = { version = "0.4.3", features = ["cors"] }
|
tower-http = { version = "0.4.3", features = ["cors"] }
|
||||||
uuid = { version = "1.4.1", features = ["v5", "serde"] }
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
use super::task::Task;
|
use super::task::Task;
|
||||||
|
|
||||||
|
@ -9,7 +8,7 @@ pub enum ClientOperation {
|
||||||
/// Set the board's title.
|
/// Set the board's title.
|
||||||
Title(String),
|
Title(String),
|
||||||
/// Create a new [`Task`], or update or delete the task with the given [`Uuid`].
|
/// Create a new [`Task`], or update or delete the task with the given [`Uuid`].
|
||||||
Task(Option<Uuid>, Option<Task>),
|
Task(Option<u64>, Option<Task>),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An operation sent from the server to the clients, and stored on the database.
|
/// An operation sent from the server to the clients, and stored on the database.
|
||||||
|
@ -18,5 +17,32 @@ pub enum ServerOperation {
|
||||||
/// Set the board's title.
|
/// Set the board's title.
|
||||||
Title(String),
|
Title(String),
|
||||||
/// Create, update, or delete the [`Task`] with the given [`Uuid`].
|
/// Create, update, or delete the [`Task`] with the given [`Uuid`].
|
||||||
Task(Uuid, Option<Task>),
|
Task(u64, Option<Task>),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ClientOperation {
|
||||||
|
fn handle(self) {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ServerOperation {
|
||||||
|
fn store(&self, rconn: redis::aio::Connection, board: &str) -> Result<()> {
|
||||||
|
log::debug!("Storing ServerOperation in Redis: {:?}", &self);
|
||||||
|
|
||||||
|
log::trace!("Serializing ServerOperation to JSON...");
|
||||||
|
let data = serde_json::ser::to_string(self)
|
||||||
|
.expect_or_500_and_log("Failed to serialize ServerOperation");
|
||||||
|
|
||||||
|
log::trace!("Computing Redis key...");
|
||||||
|
let stream_key = format!("board:{{{board}}}:stream");
|
||||||
|
|
||||||
|
log::trace!("Adding to the Redis stream {stream_key:?}...");
|
||||||
|
let response = redis::cmd("XADD")
|
||||||
|
.arg(stream_key)
|
||||||
|
.arg()
|
||||||
|
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue