garage_table/replication/
parameters.rs

1use std::time::Duration;
2
3use garage_rpc::layout::*;
4use garage_util::data::*;
5use garage_util::error::Error;
6
7/// Trait to describe how a table shall be replicated
8pub trait TableReplication: Send + Sync + 'static {
9	type WriteSets: AsRef<Vec<Vec<Uuid>>> + AsMut<Vec<Vec<Uuid>>> + Send + Sync + 'static;
10
11	const ANTI_ENTROPY_INTERVAL: Duration;
12
13	// See examples in table_sharded.rs and table_fullcopy.rs
14	// To understand various replication methods
15
16	/// The entire list of all nodes that store a partition
17	fn storage_nodes(&self, hash: &Hash) -> Result<Vec<Uuid>, Error>;
18
19	/// Which nodes to send read requests to
20	fn read_nodes(&self, hash: &Hash) -> Result<Vec<Uuid>, Error>;
21	/// Responses needed to consider a read successful
22	fn read_quorum(&self) -> Result<usize, Error>;
23
24	/// Which nodes to send writes to
25	fn write_sets(&self, hash: &Hash) -> Result<Self::WriteSets, Error>;
26	/// Responses needed to consider a write successful in each set
27	fn write_quorum(&self) -> Result<usize, Error>;
28
29	// Accessing partitions, for Merkle tree & sync
30	/// Get partition for data with given hash
31	fn partition_of(&self, hash: &Hash) -> Result<Partition, Error>;
32	/// List of partitions and nodes to sync with in current layout
33	fn sync_partitions(&self) -> Result<SyncPartitions, Error>;
34}
35
36#[derive(Debug)]
37pub struct SyncPartitions {
38	pub layout_version: u64,
39	pub partitions: Vec<SyncPartition>,
40}
41
42#[derive(Debug)]
43pub struct SyncPartition {
44	pub partition: Partition,
45	pub first_hash: Hash,
46	pub last_hash: Hash,
47	pub storage_sets: Vec<Vec<Uuid>>,
48}