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
分片策略
注意:v0.3.0 起扩展为非 Copy 枚举(新增 Enum/List/Directory/Composite
携带数据的变体)。Hash/Range/Date 三个原始变体的路由行为保持向后兼容。
Variants§
Hash
哈希分片:对 key 做哈希后取模选择 shard
Range
范围分片:按 key 的字节值范围选择 shard
Date
日期分片:按 key 中包含的日期信息(YYYY-MM-DD)选择 shard
Enum
枚举分片:显式 key → shard 映射,未匹配走默认 shard
List
列表分片:key 在预定义集合中则路由到 target,否则走默认
Fields
Directory
目录分片:动态查询路由表(key → shard)
Composite
复合分片:先按 primary 路由得到 group,再用 secondary 对 “group:key” 二级路由
Trait Implementations§
Source§impl Clone for ShardingStrategy
impl Clone for ShardingStrategy
Source§fn clone(&self) -> ShardingStrategy
fn clone(&self) -> ShardingStrategy
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ShardingStrategy
impl Debug for ShardingStrategy
Source§impl<'de> Deserialize<'de> for ShardingStrategy
impl<'de> Deserialize<'de> for ShardingStrategy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for ShardingStrategy
Source§impl PartialEq for ShardingStrategy
impl PartialEq for ShardingStrategy
Source§impl Serialize for ShardingStrategy
impl Serialize for ShardingStrategy
impl StructuralPartialEq for ShardingStrategy
Auto Trait Implementations§
impl Freeze for ShardingStrategy
impl RefUnwindSafe for ShardingStrategy
impl Send for ShardingStrategy
impl Sync for ShardingStrategy
impl Unpin for ShardingStrategy
impl UnsafeUnpin for ShardingStrategy
impl UnwindSafe for ShardingStrategy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more