Documentation
¶
Index ¶
Constants ¶
const (
TotalRedisSlots = 16384
)
Variables ¶
This section is empty.
Functions ¶
func ProcessSlotStrings ¶
Types ¶
type ClusterNodes ¶
type ClusterNodes struct {
Nodes []*Node
}
func (*ClusterNodes) CalculateSlotAssignment ¶
func (c *ClusterNodes) CalculateSlotAssignment() map[*Node][]int32
func (*ClusterNodes) ClusterMeet ¶
func (c *ClusterNodes) ClusterMeet(ctx context.Context) error
func (*ClusterNodes) GetAssignedSlots ¶
func (c *ClusterNodes) GetAssignedSlots() []int32
func (*ClusterNodes) GetMissingSlots ¶
func (c *ClusterNodes) GetMissingSlots() []int32
type Node ¶
type Node struct {
*redis.Client
NodeAttributes NodeAttributes
// contains filtered or unexported fields
}
Node represents a single Redis Node with a client, and a client builder. The client builder is necessary in case we are getting nodes from this node, for example when we load friends. We need a clientBuilder, so we can create the same base client for nodes fetched through this node, for example getting all of the attched nodes. This is especially useful for testing, as we need to pass in a mocked constructor for child clients.
func (*Node) GetFriends ¶
GetFriends returns a list of all the other Redis nodes that this node knows about
func (*Node) GetSelfAttributes ¶
func (n *Node) GetSelfAttributes(ctx context.Context) (NodeAttributes, error)
type NodeAttributes ¶
type NodeAttributes struct {
ID string
// contains filtered or unexported fields
}
NodeAttributes represents the data returned from the CLUSTER NODES commands. The format returned from Redis contains the fields, split by spaces
<id> <ip:port@cport> <flags> <master> <ping-sent> <pong-recv> <config-epoch> <link-state> <slot> <slot> ... <slot>
<id> represents the ID of the node in UUID format <ip:port@cport> part has the IP and port of the redis server, with the gossip port after @ <flags> is a string of flags separated by comma (,). Useful flags include master|slave|myself. Myself is the indicator that this line is for the calling node <master> represents the node ID that is being replicated, if the node is a slave. if it is not replicating anything it will be replaced by a dash (-) <slot>... represents slot ranges assigned to this node. The format is ranges, or single numbers. 0-4 represents all slots from 0 to 4. 8 represents the single slot 8
func NewNodeAttributes ¶
func NewNodeAttributes(nodeString string) NodeAttributes
func (*NodeAttributes) HasFlag ¶
func (n *NodeAttributes) HasFlag(flag string) bool