Documentation
¶
Overview ¶
Package cluster implements Redis Cluster style key routing with a static slot map: the keyspace is split into 16384 hash slots, each node serves a set of slot ranges, and a node answers MOVED for keys it doesn't own so cluster-aware clients learn where to send them.
There is no gossip, failover or resharding: the slot map comes from the configuration (cluster-node lines) and is the same on every node.
Index ¶
Constants ¶
const NumSlots = 16384
NumSlots is the number of hash slots, as in Redis Cluster.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Node ¶
type Node struct {
ID string
Host string
Port int
Ranges [][2]int // inclusive slot ranges, sorted
}
Node is one cluster member from the configuration.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router implements command.ClusterRouter with a static slot map.
func New ¶
New builds a router. With enabled false it only answers CLUSTER KEYSLOT style questions; Check never redirects.
func (*Router) Check ¶
Check returns an error if keys don't all hash to one slot (CROSSSLOT), or that slot is served by another node (MOVED) or nobody (CLUSTERDOWN).
func (*Router) Command ¶
Command runs a CLUSTER subcommand (args excludes "CLUSTER"). The CLUSTER command is registered with FlagAllKeys, so the caller holds every shard lock (needed by COUNTKEYSINSLOT and GETKEYSINSLOT).