Merged
Conversation
single_node() populates the SlotMap but not node.slots, so cluster_info() was reporting 0 assigned slots. derive the count from slot_map.unassigned_count() instead.
introduces ClusterCoordinator wrapping ember-cluster types for server integration. handles cluster commands (INFO, NODES, SLOTS, MYID, MEET, ADDSLOTS, DELSLOTS, FORGET), slot ownership checks with MOVED redirects, and gossip networking via UDP.
adds --cluster-enabled, --cluster-bootstrap, --cluster-port-offset, and --cluster-node-timeout flags. validates mutual exclusion with --concurrent mode. creates ClusterCoordinator on startup, spawns gossip tasks, and passes it into server::run() via ServerContext.
replaces cluster command stubs with dispatch to ClusterCoordinator when cluster mode is enabled. adds MOVED redirects on all single-key data commands and CROSSSLOT validation on multi-key commands (DEL, EXISTS, MGET, MSET, RENAME). unimplemented cluster commands now return "ERR not yet implemented" instead of "cluster support disabled".
kacy
added a commit
that referenced
this pull request
Feb 11, 2026
* fix(cluster): derive slot counts from slot_map in cluster_info single_node() populates the SlotMap but not node.slots, so cluster_info() was reporting 0 assigned slots. derive the count from slot_map.unassigned_count() instead. * feat(server): add cluster coordinator module introduces ClusterCoordinator wrapping ember-cluster types for server integration. handles cluster commands (INFO, NODES, SLOTS, MYID, MEET, ADDSLOTS, DELSLOTS, FORGET), slot ownership checks with MOVED redirects, and gossip networking via UDP. * feat(server): add cluster CLI flags and server context integration adds --cluster-enabled, --cluster-bootstrap, --cluster-port-offset, and --cluster-node-timeout flags. validates mutual exclusion with --concurrent mode. creates ClusterCoordinator on startup, spawns gossip tasks, and passes it into server::run() via ServerContext. * feat(server): wire cluster commands and add slot ownership checks replaces cluster command stubs with dispatch to ClusterCoordinator when cluster mode is enabled. adds MOVED redirects on all single-key data commands and CROSSSLOT validation on multi-key commands (DEL, EXISTS, MGET, MSET, RENAME). unimplemented cluster commands now return "ERR not yet implemented" instead of "cluster support disabled".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
wires the ember-cluster crate into the running server. this is the foundation layer — cluster mode flag, gossip networking, working CLUSTER commands, and slot ownership validation with MOVED redirects.
deferred to follow-up PRs: raft consensus, slot migration (ASK redirects), SETSLOT commands, REPLICATE, FAILOVER.
what changed
cluster_info()was reporting 0 assigned slots becausesingle_node()populates theSlotMapbut notnode.slots. now derives the count fromslot_map.unassigned_count().cluster.rs:ClusterCoordinatorwrapping cluster crate types with command handlers, slot ownership checks, and gossip UDP networking.--cluster-enabled,--cluster-bootstrap,--cluster-port-offset,--cluster-node-timeout. validates mutual exclusion with--concurrent.what was tested
cargo clippy --workspace -- -D warnings— cleancargo test --workspace— all 296 tests pass, no regressionscluster_info_formattest to assertcluster_slots_assigned:16384(was incorrectly asserting 0)design considerations
ClusterCoordinatorusesRwLock<ClusterState>for many-reader/rare-writer access andMutex<GossipEngine>for the gossip tick loop. the read lock is only held briefly during slot checks so it shouldn't be a bottleneck.GossipEvents and update cluster state. both are spawned before the accept loop starts.check_cluster_slotreturns early with MOVED). when cluster isNone, the check is a no-op (zero overhead).check_crossslotis synchronous (no lock needed) since it only computes hash slots from key bytes.