garage/src/table/replication/parameters.rs

27 lines
871 B
Rust
Raw Normal View History

2021-03-16 11:18:03 +00:00
use garage_rpc::ring::*;
2021-03-11 15:54:15 +00:00
use garage_util::data::*;
2021-03-26 18:41:46 +00:00
/// Trait to describe how a table shall be replicated
2021-03-11 15:54:15 +00:00
pub trait TableReplication: Send + Sync {
// See examples in table_sharded.rs and table_fullcopy.rs
// To understand various replication methods
2021-03-26 18:41:46 +00:00
/// Which nodes to send read requests to
2021-05-02 21:13:08 +00:00
fn read_nodes(&self, hash: &Hash) -> Vec<Uuid>;
2021-03-26 18:41:46 +00:00
/// Responses needed to consider a read succesfull
2021-03-11 15:54:15 +00:00
fn read_quorum(&self) -> usize;
2021-03-26 18:41:46 +00:00
/// Which nodes to send writes to
2021-05-02 21:13:08 +00:00
fn write_nodes(&self, hash: &Hash) -> Vec<Uuid>;
2021-03-26 18:41:46 +00:00
/// Responses needed to consider a write succesfull
2021-03-16 10:14:27 +00:00
fn write_quorum(&self) -> usize;
2021-03-11 15:54:15 +00:00
fn max_write_errors(&self) -> usize;
2021-03-16 11:18:03 +00:00
// Accessing partitions, for Merkle tree & sync
2021-03-26 18:41:46 +00:00
/// Get partition for data with given hash
2021-03-16 11:18:03 +00:00
fn partition_of(&self, hash: &Hash) -> Partition;
2021-03-26 18:41:46 +00:00
/// List of existing partitions
2021-03-16 11:18:03 +00:00
fn partitions(&self) -> Vec<(Partition, Hash)>;
2021-03-11 15:54:15 +00:00
}