use crate::error::ProtocolError;
use crate::ids::{ClientId, LogIndex, NodeId, Term};
use crate::log::LogEntry;
use crate::membership::ConfigChange;
use crate::message::Message;
use crate::snapshot::SnapshotMeta;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ClientResult {
Committed,
NotLeader {
leader: Option<NodeId>,
},
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ConfigResult {
Committed,
NotLeader {
leader: Option<NodeId>,
},
Rejected {
error: ProtocolError,
},
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Action {
Send {
to: NodeId,
msg: Message,
},
PersistHardState {
current_term: Term,
voted_for: Option<NodeId>,
},
PersistEntries {
from_index: LogIndex,
entries: Vec<LogEntry>,
},
Apply {
index: LogIndex,
entry: LogEntry,
},
ReadReady {
request_id: u64,
key: Vec<u8>,
read_index: LogIndex,
},
ReadRejected {
request_id: u64,
leader: Option<NodeId>,
},
ClientResponse {
client_id: ClientId,
seq: u64,
result: ClientResult,
},
PersistSnapshot {
meta: SnapshotMeta,
data: Vec<u8>,
},
LoadSnapshot {
meta: SnapshotMeta,
},
ConfigResponse {
change: ConfigChange,
result: ConfigResult,
},
StepDown {
term: Term,
},
}