Skip to content

feat: wire remaining cluster commands#74

Merged
kacy merged 4 commits intomainfrom
feat/wire-cluster-commands
Feb 10, 2026
Merged

feat: wire remaining cluster commands#74
kacy merged 4 commits intomainfrom
feat/wire-cluster-commands

Conversation

@kacy
Copy link
Copy Markdown
Owner

@kacy kacy commented Feb 10, 2026

summary

wires 7 of the 9 "not yet implemented" cluster commands in connection.rs:

  • SETSLOT IMPORTING/MIGRATING/NODE/STABLE — delegates to new ClusterCoordinator methods backed by MigrationManager from ember-cluster
  • COUNTKEYSINSLOT — broadcasts to all shards, sums key counts matching the slot
  • GETKEYSINSLOT — broadcasts to all shards, aggregates keys, truncates to requested count
  • REPLICATE/FAILOVER — honest "not yet supported" stubs (replication isn't built)
  • MIGRATE — kept as "not yet implemented" (needs remote TCP connections)

adds count_keys_in_slot() and get_keys_in_slot() to keyspace with corresponding shard request/response variants.

what was tested

  • 768 tests pass across the workspace (301 in emberkv-core, 270 in ember-protocol, 66 in ember-persistence, 56 in ember-cluster, 43 in ember-server, 32 in emberkv-cli)
  • new unit tests for keyspace slot queries (5 tests)
  • new unit tests for SETSLOT handlers (10 tests covering valid paths, edge cases, and error conditions)
  • cargo clippy --workspace -- -D warnings clean

design considerations

  • keyspace slot queries are O(n) scans — same as KEYS. acceptable for cluster management commands
  • MigrationManager added to ClusterCoordinator behind a Mutex since migration state changes are infrequent
  • ember-cluster added as a dependency of emberkv-core for the key_slot function

kacy added 4 commits February 9, 2026 20:43
add count_keys_in_slot and get_keys_in_slot methods to keyspace for
cluster slot inspection. add corresponding shard request/response
variants and dispatch handlers. these support the CLUSTER COUNTKEYSINSLOT
and CLUSTER GETKEYSINSLOT commands.
add MigrationManager to ClusterCoordinator and implement the four
SETSLOT subcommands: IMPORTING, MIGRATING, NODE, and STABLE. validates
slot ranges, node IDs, and ownership before starting migrations.
replace "not yet implemented" stubs with real dispatch:
- SETSLOT IMPORTING/MIGRATING/NODE/STABLE → cluster coordinator
- COUNTKEYSINSLOT → broadcast to shards, sum counts
- GETKEYSINSLOT → broadcast to shards, aggregate and truncate
- REPLICATE/FAILOVER → honest "not yet supported" error
- MIGRATE → kept as not implemented (needs remote connections)
covers importing, migrating, node, and stable subcommands including
edge cases: invalid slot, self-import/migrate rejection, duplicate
migration, non-owner migration, node assignment, migration cleanup,
and stable noop.
@kacy kacy merged commit f624421 into main Feb 10, 2026
6 of 7 checks passed
@kacy kacy deleted the feat/wire-cluster-commands branch February 10, 2026 01:51
kacy added a commit that referenced this pull request Feb 11, 2026
* feat: add slot-aware key queries to keyspace and shard

add count_keys_in_slot and get_keys_in_slot methods to keyspace for
cluster slot inspection. add corresponding shard request/response
variants and dispatch handlers. these support the CLUSTER COUNTKEYSINSLOT
and CLUSTER GETKEYSINSLOT commands.

* feat: add SETSLOT command handlers to cluster coordinator

add MigrationManager to ClusterCoordinator and implement the four
SETSLOT subcommands: IMPORTING, MIGRATING, NODE, and STABLE. validates
slot ranges, node IDs, and ownership before starting migrations.

* feat: wire remaining cluster commands in connection handler

replace "not yet implemented" stubs with real dispatch:
- SETSLOT IMPORTING/MIGRATING/NODE/STABLE → cluster coordinator
- COUNTKEYSINSLOT → broadcast to shards, sum counts
- GETKEYSINSLOT → broadcast to shards, aggregate and truncate
- REPLICATE/FAILOVER → honest "not yet supported" error
- MIGRATE → kept as not implemented (needs remote connections)

* test: add unit tests for SETSLOT command handlers

covers importing, migrating, node, and stable subcommands including
edge cases: invalid slot, self-import/migrate rejection, duplicate
migration, non-owner migration, node assignment, migration cleanup,
and stable noop.
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