Expand description
Mesh Gossip Protocol and Distributed State Synchronization
This crate provides mesh networking capabilities for distributed cluster state management:
- Gossip protocol for node discovery and failure detection
- CRDT-based state synchronization across cluster nodes
- Consistent hashing for request routing
- Partition detection and recovery
Modules§
Macros§
Structs§
- AppState
- App state entry (application configuration)
- Crdt
OrMap - CRDT OR-Map
- MTLS
Config - mTLS configuration
- MTLS
Manager - mTLS certificate manager
- Membership
State - Membership state entry
- Mesh
Server Builder - Mesh
Server Config - Mesh
Server Handler - MeshServerHandler It is the handler for the mesh server, which is responsible for the node management. Includes some basic node management logic, like shutdown, node discovery(TODO), node status update(TODO), etc.
- Mesh
Sync Manager - Mesh sync manager for coordinating state synchronization
- Operation
Log - Operation log, recording all state changes
- Partition
Detector - Partition detector
- Rate
Limit Config - Global rate limit configuration
- Rate
Limit Window - Rate limit window manager Handles periodic reset of rate limit counters for time window management
- State
Stores - All state stores container
- Tenant
Delta - Lightweight tenant change set for high-frequency sync (every gossip round). Contains only which tenants changed at which tree nodes — no tree structure, no prompt text. ~100 bytes per insert vs ~200KB for full TreeOperation.
- Tenant
Evict - A tenant was evicted from a tree node.
- Tenant
Insert - A tenant was added or refreshed at a tree node.
- Tree
Insert Op - Tree insert operation
- Tree
Remove Op - Tree remove operation
- Tree
State - Tree state for a specific model Contains a sequence of operations that can be applied to reconstruct the tree
- Worker
State - Worker state entry synced across mesh nodes.
Enums§
- TreeKey
- Tree
Operation - Tree operation type
Constants§
- GLOBAL_
EVICTION_ HASH - Sentinel value for
TenantEvict.node_path_hashmeaning “evict this tenant from ALL nodes” (global eviction). - GLOBAL_
RATE_ LIMIT_ COUNTER_ KEY - Key for global rate limit counter in RateLimitStore
- GLOBAL_
RATE_ LIMIT_ KEY - Key for global rate limit configuration in AppStore
Traits§
Functions§
- hash_
node_ path - Compute a compact 8-byte hash of a prefix path for node identification.
Returns a non-zero hash; 0 is reserved for
GLOBAL_EVICTION_HASH. - hash_
token_ path - Compute a compact 8-byte hash from token IDs.
Returns a non-zero hash; 0 is reserved for
GLOBAL_EVICTION_HASH. - init_
mesh_ metrics - Initialize mesh metrics descriptions
- lz4_
compress - Compress bytes with LZ4 for wire efficiency. Radix tree data compresses well (repetitive edge labels, worker URLs).
- lz4_
decompress - Decompress LZ4-compressed bytes with a size safety check. Rejects payloads claiming > 256 MB decompressed size to prevent OOM from corrupted or malicious size headers.
Type Aliases§
- Cluster
State - OptionalMTLS
Manager - Optional mTLS manager
- Optional
Mesh Sync Manager - Optional mesh sync manager (can be None if mesh is not enabled)