redis

package
v0.0.0-...-010c68d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TotalRedisSlots = 16384
)

Variables

This section is empty.

Functions

func ProcessSlotStrings

func ProcessSlotStrings(slotStrings []string) []int32

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) MoveSlot

func (c *ClusterNodes) MoveSlot(ctx context.Context, source, destination *Node, slot int) error

MoveSlot moves a single slot from one node to another

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 NewNode

func NewNode(ctx context.Context, opt *redis.Options, pod *v1.Pod, clientBuilder func(opt *redis.Options) *redis.Client) (*Node, error)

func (*Node) GetFriends

func (n *Node) GetFriends(ctx context.Context) ([]*Node, error)

GetFriends returns a list of all the other Redis nodes that this node knows about

func (*Node) GetOrdinal

func (n *Node) GetOrdinal() int32

func (*Node) GetSelfAttributes

func (n *Node) GetSelfAttributes(ctx context.Context) (NodeAttributes, error)

func (*Node) IsMaster

func (n *Node) IsMaster() bool

func (*Node) MeetNode

func (n *Node) MeetNode(ctx context.Context, node *Node) error

MeetNode let's the node recognise and connect to another Redis Node

func (*Node) NeedsSlotCount

func (n *Node) NeedsSlotCount(cluster *v1alpha1.RedisCluster) int32

func (*Node) ReloadNodeInfo

func (n *Node) ReloadNodeInfo(ctx context.Context) 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) 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL