35 lines
954 B
Rust
35 lines
954 B
Rust
|
|
use swactor::actor::ActorAddress;
|
||
|
|
|
||
|
|
use crate::state::GossipState;
|
||
|
|
|
||
|
|
#[derive(Debug, Clone)]
|
||
|
|
pub enum GossipMessage {
|
||
|
|
/// Register a peer to gossip with.
|
||
|
|
AddPeer(ActorAddress),
|
||
|
|
/// Remove a peer from the gossip set.
|
||
|
|
RemovePeer(ActorAddress),
|
||
|
|
/// Set a key-value pair in this node's local state.
|
||
|
|
Set { key: String, value: Vec<u8> },
|
||
|
|
/// Trigger a gossip round: pick a random peer and push our full state.
|
||
|
|
DoGossipRound,
|
||
|
|
/// Incoming state push from a peer.
|
||
|
|
Push {
|
||
|
|
from: ActorAddress,
|
||
|
|
state: GossipState,
|
||
|
|
},
|
||
|
|
/// Query the current value for a key; response sent to `reply_to`.
|
||
|
|
Query {
|
||
|
|
key: String,
|
||
|
|
reply_to: ActorAddress,
|
||
|
|
},
|
||
|
|
/// Ask the actor to dump its current state into the event log (tracing only).
|
||
|
|
TakeSnapshot,
|
||
|
|
}
|
||
|
|
|
||
|
|
#[derive(Debug, Clone)]
|
||
|
|
pub struct GossipQueryResponse {
|
||
|
|
pub key: String,
|
||
|
|
pub value: Option<Vec<u8>>,
|
||
|
|
pub version: Option<u64>,
|
||
|
|
}
|