summaryrefslogtreecommitdiff
path: root/broadcast/src/msg.rs
diff options
context:
space:
mode:
authorAria <me@aria.rip>2023-10-13 14:13:58 +0100
committerAria <me@aria.rip>2023-10-13 14:13:58 +0100
commitb2d679f05d04052bfc25167eaaf09c60c03251cb (patch)
tree7ca49d117a3167169e5b92613ca21c88c12bd47f /broadcast/src/msg.rs
parentc063f4da42a538138cc3e80a0e1faaf813a13bd2 (diff)
wip: fault tolerant broadcast
Diffstat (limited to 'broadcast/src/msg.rs')
-rw-r--r--broadcast/src/msg.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/broadcast/src/msg.rs b/broadcast/src/msg.rs
new file mode 100644
index 0000000..6433982
--- /dev/null
+++ b/broadcast/src/msg.rs
@@ -0,0 +1,36 @@
+use common::msg_id::MessageID;
+use serde::{Deserialize, Serialize};
+use std::collections::{HashMap, HashSet};
+
+pub type BroadcastTarget = usize;
+
+#[derive(Debug, Deserialize, Serialize, Clone)]
+#[serde(tag = "type")]
+pub enum BroadcastBody {
+ #[serde(rename = "broadcast")]
+ Broadcast {
+ msg_id: Option<MessageID>,
+ message: BroadcastTarget,
+ },
+
+ #[serde(rename = "broadcast_ok")]
+ BroadcastOk { in_reply_to: MessageID },
+
+ #[serde(rename = "topology")]
+ Topology {
+ msg_id: Option<MessageID>,
+ topology: HashMap<String, Vec<String>>,
+ },
+
+ #[serde(rename = "topology_ok")]
+ TopologyOk { in_reply_to: MessageID },
+
+ #[serde(rename = "read")]
+ Read { msg_id: MessageID },
+
+ #[serde(rename = "read_ok")]
+ ReadOk {
+ in_reply_to: MessageID,
+ messages: HashSet<BroadcastTarget>,
+ },
+}