pub enum ShardingStrategy {
Hash,
Range,
Date,
Enum {
mapping: HashMap<String, String>,
default: Option<String>,
},
List {
keys: HashSet<String>,
target: String,
default: Option<String>,
},
Directory {
table: HashMap<String, String>,
},
Composite {
primary: Box<ShardingStrategy>,
primary_shards: Vec<String>,
secondary: Box<ShardingStrategy>,
secondary_shards: Vec<String>,
},
}Expand description
Sharding strategy.
Note: from v0.3.0 this is extended to a non-Copy enum (with new
Enum/List/Directory/Composite variants that carry data). The routing
behavior of the three original variants Hash/Range/Date remains
backward compatible.
Variants§
Hash
Hash sharding: hash the key and select a shard by modulo.
Range
Range sharding: select a shard by the byte-value range of the key.
Date
Date sharding: select a shard by the date information (YYYY-MM-DD) in the key.
Enum
Enum sharding: explicit key → shard mapping; unmatched keys go to the default shard.
Fields
List
List sharding: route to target if the key is in the predefined set, otherwise default.
Fields
Directory
Directory sharding: dynamically query a routing table (key → shard).
Composite
Composite sharding: first route by primary to obtain a group, then route
“group:key” with secondary for the second-level routing.
Fields
primary: Box<ShardingStrategy>Primary strategy (decides the group).
secondary: Box<ShardingStrategy>Secondary strategy (routes within the group).
Trait Implementations§
Source§impl Clone for ShardingStrategy
impl Clone for ShardingStrategy
Source§fn clone(&self) -> ShardingStrategy
fn clone(&self) -> ShardingStrategy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more