Documentation
¶
Index ¶
- Constants
- func ProcessSlotStrings(slotStrings []string) []int32
- type ClusterNodes
- func (c *ClusterNodes) BalanceSlots(ctx context.Context, cluster *v1alpha1.RedisCluster) error
- func (c *ClusterNodes) CalculateRebalance(ctx context.Context, cluster *v1alpha1.RedisCluster) []slotMoveMap
- func (c *ClusterNodes) CalculateRemoveNodes(ctx context.Context, cluster *v1alpha1.RedisCluster) []slotMoveMap
- func (c *ClusterNodes) CalculateSlotAssignment() map[*Node][]int32
- func (c *ClusterNodes) ClusterMeet(ctx context.Context) error
- func (c *ClusterNodes) DrainNodes(ctx context.Context, cluster *v1alpha1.RedisCluster) error
- func (c *ClusterNodes) EnsureClusterReplicationRatio(ctx context.Context, cluster *v1alpha1.RedisCluster) error
- func (c *ClusterNodes) ForgetNode(ctx context.Context, forgetNode *Node) error
- func (c *ClusterNodes) GetAssignedSlots() []int32
- func (c *ClusterNodes) GetCommandingNode(ctx context.Context) (*Node, error)
- func (c *ClusterNodes) GetFailingNodes(ctx context.Context) ([]*Node, error)
- func (c *ClusterNodes) GetMasters() []*Node
- func (c *ClusterNodes) GetMissingSlots() []int32
- func (c *ClusterNodes) GetReplicas() []*Node
- func (c *ClusterNodes) MoveSlot(ctx context.Context, source, destination *Node, slot int) error
- func (c *ClusterNodes) ReloadNodes(ctx context.Context) error
- type Node
- func (n *Node) GetFriends(ctx context.Context) ([]*Node, error)
- func (n *Node) GetOrdinal() int32
- func (n *Node) GetSelfAttributes(ctx context.Context) (NodeAttributes, error)
- func (n *Node) IsMaster() bool
- func (n *Node) MeetNode(ctx context.Context, node *Node) error
- func (n *Node) NeedsSlotCount(cluster *v1alpha1.RedisCluster) int32
- func (n *Node) ReloadNodeInfo(ctx context.Context) error
- type NodeAttributes
Constants ¶
const (
TotalRedisSlots = 16384
)
Variables ¶
This section is empty.
Functions ¶
func ProcessSlotStrings ¶
Types ¶
type ClusterNodes ¶
type ClusterNodes struct {
Nodes []*Node
}
func (*ClusterNodes) BalanceSlots ¶
func (c *ClusterNodes) BalanceSlots(ctx context.Context, cluster *v1alpha1.RedisCluster) error
func (*ClusterNodes) CalculateRebalance ¶
func (c *ClusterNodes) CalculateRebalance(ctx context.Context, cluster *v1alpha1.RedisCluster) []slotMoveMap
func (*ClusterNodes) CalculateRemoveNodes ¶
func (c *ClusterNodes) CalculateRemoveNodes(ctx context.Context, cluster *v1alpha1.RedisCluster) []slotMoveMap
func (*ClusterNodes) CalculateSlotAssignment ¶
func (c *ClusterNodes) CalculateSlotAssignment() map[*Node][]int32
func (*ClusterNodes) ClusterMeet ¶
func (c *ClusterNodes) ClusterMeet(ctx context.Context) error
func (*ClusterNodes) DrainNodes ¶
func (c *ClusterNodes) DrainNodes(ctx context.Context, cluster *v1alpha1.RedisCluster) error
func (*ClusterNodes) EnsureClusterReplicationRatio ¶
func (c *ClusterNodes) EnsureClusterReplicationRatio(ctx context.Context, cluster *v1alpha1.RedisCluster) error
func (*ClusterNodes) ForgetNode ¶
func (c *ClusterNodes) ForgetNode(ctx context.Context, forgetNode *Node) error
func (*ClusterNodes) GetAssignedSlots ¶
func (c *ClusterNodes) GetAssignedSlots() []int32
func (*ClusterNodes) GetCommandingNode ¶
func (c *ClusterNodes) GetCommandingNode(ctx context.Context) (*Node, error)
func (*ClusterNodes) GetFailingNodes ¶
func (c *ClusterNodes) GetFailingNodes(ctx context.Context) ([]*Node, error)
GetFailingNodes returns a list of all the nodes marked as failing in the cluster. Any nodes marked as failing in `cluster nodes` command will be returned We will most likely not be able to connect to these nodes as they would be restarted pods
func (*ClusterNodes) GetMasters ¶
func (c *ClusterNodes) GetMasters() []*Node
func (*ClusterNodes) GetMissingSlots ¶
func (c *ClusterNodes) GetMissingSlots() []int32
func (*ClusterNodes) GetReplicas ¶
func (c *ClusterNodes) GetReplicas() []*Node
func (*ClusterNodes) ReloadNodes ¶
func (c *ClusterNodes) ReloadNodes(ctx context.Context) error
type Node ¶
type Node struct { *redis.Client NodeAttributes NodeAttributes PodDetails *v1.Pod // 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) GetOrdinal ¶
func (*Node) GetSelfAttributes ¶
func (n *Node) GetSelfAttributes(ctx context.Context) (NodeAttributes, error)
func (*Node) NeedsSlotCount ¶
func (n *Node) NeedsSlotCount(cluster *v1alpha1.RedisCluster) int32
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) GetHost ¶
func (n *NodeAttributes) GetHost() string
func (*NodeAttributes) GetPort ¶
func (n *NodeAttributes) GetPort() string
func (*NodeAttributes) GetSlots ¶
func (n *NodeAttributes) GetSlots() []int32
func (*NodeAttributes) HasFlag ¶
func (n *NodeAttributes) HasFlag(flag string) bool