Squashed diff from mh-backend-shard

This commit is contained in:
Maciej Hirsz
2021-06-08 12:17:00 +02:00
parent 505e5a387e
commit 8db384bed3
30 changed files with 1688 additions and 457 deletions
+38
View File
@@ -0,0 +1,38 @@
use std::net::Ipv4Addr;
use crate::ws::MuteReason;
use crate::node::Payload;
use crate::types::{NodeId, NodeDetails};
use serde::{Deserialize, Serialize};
/// Alias for the ID of the node connection
pub type ShardConnId = u32;
/// Message sent from the shard to the backend core
#[derive(Deserialize, Serialize, Debug)]
pub enum ShardMessage {
/// Get a connection id for a new node, passing IPv4
AddNode {
ip: Option<Ipv4Addr>,
node: NodeDetails,
sid: ShardConnId,
},
/// Send a message payload for a given node
UpdateNode {
nid: NodeId,
payload: Payload,
},
}
/// Message sent form the backend core to the shard
#[derive(Deserialize, Serialize, Debug)]
pub enum BackendMessage {
Initialize {
sid: ShardConnId,
nid: NodeId,
},
Mute {
sid: ShardConnId,
reason: MuteReason,
},
}