Ferricstore.Commands.Cluster (ferricstore v0.3.2)

Copy Markdown View Source

Handles FerricStore cluster inspection and management commands.

Provides per-shard health and statistics information by querying the ETS tables owned by each shard GenServer, plus cluster membership operations.

Supported commands

Inspection

  • CLUSTER.HEALTH -- returns per-shard status including role, health, key count, and memory usage
  • CLUSTER.STATS -- returns per-shard key/memory stats plus totals
  • CLUSTER.KEYSLOT <key> -- returns the hash slot for a key
  • CLUSTER.SLOTS -- returns slot range assignments
  • CLUSTER.STATUS -- returns detailed cluster info: nodes, per-shard leader/follower info, roles
  • CLUSTER.ROLE -- returns this node's configured cluster role

Membership management

  • CLUSTER.JOIN <node> -- adds a node to the cluster
  • CLUSTER.LEAVE -- gracefully removes this node from the cluster
  • CLUSTER.FAILOVER <shard_index> <target_node> -- transfers shard leadership to a specific node
  • CLUSTER.PROMOTE <node> -- promotes a replica to voter for all shards
  • CLUSTER.DEMOTE <node> -- demotes a voter to replica for all shards

Summary

Functions

Handles a cluster command.

Functions

handle(cmd, args, store)

@spec handle(binary(), [binary()], map()) :: term()

Handles a cluster command.

Parameters

  • cmd - uppercased command name (e.g. "CLUSTER.HEALTH")
  • args - list of string arguments
  • _store - injected store map (unused by cluster commands)

Returns

A list of bulk strings formatted as key-value pairs for RESP3 encoding.