aboutsummaryrefslogtreecommitdiff
path: root/src/util/config.rs
diff options
context:
space:
mode:
authorYureka <yuka@yuka.dev>2024-03-04 19:58:32 +0100
committerYureka <yuka@yuka.dev>2024-03-07 12:45:33 +0100
commitc1769bbe69f723fb3980cf4fdac7615cfb782720 (patch)
treee623904bbdc861b42039057d6a1e982486fc60b4 /src/util/config.rs
parent8f86af52ed917bce506989ae1f378d977aa6c3ef (diff)
downloadgarage-c1769bbe69f723fb3980cf4fdac7615cfb782720.tar.gz
garage-c1769bbe69f723fb3980cf4fdac7615cfb782720.zip
ReplicationMode -> ConsistencyMode+ReplicationFactor
Diffstat (limited to 'src/util/config.rs')
-rw-r--r--src/util/config.rs27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/util/config.rs b/src/util/config.rs
index 056c625d..b7f27676 100644
--- a/src/util/config.rs
+++ b/src/util/config.rs
@@ -30,12 +30,20 @@ pub struct Config {
)]
pub block_size: usize,
- /// Replication mode. Supported values:
- /// - none, 1 -> no replication
- /// - 2 -> 2-way replication
- /// - 3 -> 3-way replication
- // (we can add more aliases for this later)
- pub replication_mode: String,
+ /// Number of replicas. Can be any positive integer, but uneven numbers are more favorable.
+ /// - 1 for single-node clusters, or to disable replication
+ /// - 3 is the recommended and supported setting.
+ #[serde(default)]
+ pub replication_factor: Option<usize>,
+
+ /// Consistency mode for all for requests through this node
+ /// - Degraded -> Disable read quorum
+ /// - Dangerous -> Disable read and write quorum
+ #[serde(default = "default_consistency_mode")]
+ pub consistency_mode: String,
+
+ /// Legacy option
+ pub replication_mode: Option<String>,
/// Zstd compression level used on data blocks
#[serde(
@@ -244,10 +252,15 @@ fn default_sled_cache_capacity() -> usize {
fn default_sled_flush_every_ms() -> u64 {
2000
}
+
fn default_block_size() -> usize {
1048576
}
+fn default_consistency_mode() -> String {
+ "consistent".into()
+}
+
fn default_compression() -> Option<i32> {
Some(1)
}
@@ -359,7 +372,7 @@ mod tests {
r#"
metadata_dir = "/tmp/garage/meta"
data_dir = "/tmp/garage/data"
- replication_mode = "3"
+ replication_factor = 3
rpc_bind_addr = "[::]:3901"
rpc_secret = "foo"