make the consistency configurable

This commit is contained in:
Tamo
2023-03-21 18:25:53 +01:00
parent 8ebc2b19ea
commit 3df58831c6
6 changed files with 38 additions and 10 deletions

View File

@ -1,4 +1,5 @@
use std::net::ToSocketAddrs;
use std::str::FromStr;
use std::sync::{Arc, RwLock};
use batch::Batch;
@ -40,14 +41,30 @@ pub enum FollowerMsg {
RegisterNewTask(KindWithContent),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Default, Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
pub enum Consistency {
#[default]
One,
Two,
Quorum,
All,
}
impl std::fmt::Display for Consistency {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let s = serde_json::to_string(self).unwrap();
write!(f, "{s}")
}
}
impl FromStr for Consistency {
type Err = serde_json::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
serde_json::from_str(s)
}
}
#[derive(Clone)]
pub struct Follower {
sender: ChannelSender<FollowerMsg>,