Skip to content

feat(cluster): add slot management and topology foundations - #31

Merged
kacy merged 2 commits into
mainfrom
feat/cluster-topology
Feb 6, 2026
Merged

feat(cluster): add slot management and topology foundations#31
kacy merged 2 commits into
mainfrom
feat/cluster-topology

Conversation

@kacy

@kacy kacy commented Feb 6, 2026

Copy link
Copy Markdown
Owner

summary

implements the core building blocks for redis cluster compatibility:

  • slots.rs: CRC16 hash function (redis-compatible), SlotMap for 16384 slot distribution, SlotRange for contiguous slot assignments, hash tag extraction for key co-location
  • topology.rs: NodeId (uuid-based), ClusterNode with roles and health, ClusterState for full cluster view, MOVED redirect generation, CLUSTER INFO and CLUSTER NODES output formatting
  • error.rs: ClusterError enum for MOVED, ASK, and other cluster errors
  • protocol extensions: CLUSTER INFO/NODES/SLOTS/KEYSLOT/MYID commands and ASKING flag

this lays the foundation for gossip-based membership, raft consensus, and live slot migration.

what was tested

  • unit tests for CRC16 implementation verified against known redis slot assignments
  • unit tests for hash tag extraction ({tag} syntax)
  • unit tests for SlotMap operations (assignment, ranges, ownership queries)
  • unit tests for ClusterNode and ClusterState (creation, health checks, redirects)
  • unit tests for all CLUSTER command parsing
  • cargo clippy -- -D warnings passes
  • cargo test -p ember-cluster -p ember-protocol all 203+ tests pass

design considerations

  • used the exact CRC16 lookup table from redis source for guaranteed compatibility
  • SlotMap uses a boxed array to avoid 128KB stack allocation
  • NodeId wraps UUID v4 for cluster-wide uniqueness
  • cluster bus port defaults to data port + 10000 (redis convention)
  • CLUSTER KEYSLOT is fully functional; other cluster commands return stubs until full integration

kacy added 2 commits February 5, 2026 23:18
implements the core building blocks for redis cluster compatibility:

- slots.rs: CRC16 hash function (redis-compatible), SlotMap for 16384
  slot distribution, SlotRange for contiguous slot assignments, hash
  tag extraction for key co-location
- topology.rs: NodeId (uuid-based), ClusterNode with roles and health,
  ClusterState for full cluster view, MOVED redirect generation,
  CLUSTER INFO and CLUSTER NODES output formatting
- error.rs: ClusterError enum for MOVED, ASK, and other cluster errors

all modules include comprehensive unit tests. the crc16 implementation
is verified against known redis slot assignments.
adds CLUSTER subcommands and ASKING to the protocol layer:

- CLUSTER INFO: returns cluster state (stub for now)
- CLUSTER NODES: returns node list (stub for now)
- CLUSTER SLOTS: returns slot distribution (stub for now)
- CLUSTER KEYSLOT: computes hash slot for a key (fully working)
- CLUSTER MYID: returns node id (stub for now)
- ASKING: migration hint flag (no-op for now)

integrates ember-cluster crate into ember-server for slot calculation.
includes comprehensive tests for all new command parsing.
@kacy
kacy merged commit 748f0a2 into main Feb 6, 2026
5 checks passed
@kacy
kacy deleted the feat/cluster-topology branch February 7, 2026 20:06
kacy added a commit that referenced this pull request Feb 11, 2026
feat(cluster): add slot management and topology foundations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant