Documentation ¶
Index ¶
- Constants
- Variables
- func CheckandUpdateClusterState(cinfos *ClusterInfos, cs clusterstate, fromip string, nip string, ...) error
- func Contains(s []Slot, e Slot) bool
- func DecodeNodeStartTime(input *string, log logr.Logger) (time.Time, error)
- func DecodeSlotRange(str string) ([]Slot, *ImportingSlot, *MigratingSlot, error)
- func IsInconsistentError(err error) bool
- func IsNodeNotFoundedError(err error) bool
- func IsPartialError(err error) bool
- func LessByID(n1, n2 *Node) bool
- func MoreByID(n1, n2 *Node) bool
- func NewClient(ctx context.Context, addr string, password string, cnxTimeout time.Duration, ...) (*redis.Client, error)
- type Admin
- func (a *Admin) AddSlots(ctx context.Context, addr string, slots []Slot) error
- func (a *Admin) AttachNodeToCluster(ctx context.Context, addr string) error
- func (a *Admin) AttachSlaveToMaster(ctx context.Context, slave *Node, masterID string) error
- func (a *Admin) Close(ctx context.Context)
- func (a *Admin) ClusterManagerNodeIsEmpty(ctx context.Context) (bool, error)
- func (a *Admin) Connections() IAdminConnections
- func (a *Admin) DetachSlave(ctx context.Context, slave *Node) error
- func (a *Admin) FailoverSlaveToMaster(ctx context.Context, slave *Node, option RedisFailover) error
- func (a *Admin) FlushAndReset(ctx context.Context, addr string, mode string) error
- func (a *Admin) ForgetNode(ctx context.Context, id string) error
- func (a *Admin) GetAllConfig(ctx context.Context, c *redis.Client, addr string) (map[string]string, error)
- func (a *Admin) GetClusterInfos(ctx context.Context) (*ClusterInfos, error)
- func (a *Admin) GetHashMaxSlot() Slot
- func (a *Admin) GetSlaveStatus(ip string, ctx context.Context) (string, error)
- func (a *Admin) MigrateKeys(ctx context.Context, addr string, dest *Node, slots []Slot, batch int, ...) (int, error)
- func (a *Admin) MigrateKeysInSlot(ctx context.Context, addr string, dest *Node, slot Slot, batch int, ...) (int, error)
- func (a *Admin) ResetPassword(ctx context.Context, newPassword string) error
- func (a *Admin) SetConfigEpoch(ctx context.Context) error
- func (a *Admin) SetConfigIfNeed(ctx context.Context, newConfig map[string]string) error
- func (a *Admin) SetSlot(ctx context.Context, addr, action string, slot Slot, nodeID string) error
- func (a *Admin) SetSlots(ctx context.Context, addr, action string, slots []Slot, nodeID string) error
- type AdminConnections
- func (cnx *AdminConnections) Add(ctx context.Context, addr string) error
- func (cnx *AdminConnections) AddAll(ctx context.Context, addrs []string)
- func (cnx *AdminConnections) Close(ctx context.Context)
- func (cnx *AdminConnections) Get(ctx context.Context, addr string) (*redis.Client, error)
- func (cnx *AdminConnections) GetAUTH() (string, bool)
- func (cnx *AdminConnections) GetAll() map[string]*redis.Client
- func (cnx *AdminConnections) GetDifferentFrom(addr string) (*redis.Client, error)
- func (cnx *AdminConnections) GetRandom() (*redis.Client, error)
- func (cnx *AdminConnections) GetSelected(addrs []string) map[string]*redis.Client
- func (cnx *AdminConnections) Reconnect(ctx context.Context, addr string) error
- func (cnx *AdminConnections) Remove(ctx context.Context, addr string)
- func (cnx *AdminConnections) ReplaceAll(ctx context.Context, addrs []string)
- func (cnx *AdminConnections) Reset(ctx context.Context)
- func (cnx *AdminConnections) Update(ctx context.Context, addr string) (*redis.Client, error)
- func (cnx *AdminConnections) ValidatePipeResp(ctx context.Context, resp []redis.Cmder, addr string, err error, ...) bool
- func (cnx *AdminConnections) ValidateResp(ctx context.Context, resp *redis.Cmd, addr, errMessage string) error
- type AdminOptions
- type Cluster
- func (c *Cluster) AddNode(node *Node)
- func (c *Cluster) GetNodeByFunc(f FindNodeFunc) (*Node, error)
- func (c *Cluster) GetNodeByID(id string) (*Node, error)
- func (c *Cluster) GetNodeByIP(ip string) (*Node, error)
- func (c *Cluster) GetNodeByPodName(name string) (*Node, error)
- func (c *Cluster) GetNodesByFunc(f FindNodeFunc) (Nodes, error)
- type ClusterActionsInfo
- type ClusterInfos
- type ClusterInfosError
- type ConfigSignature
- type CustomType
- type Error
- type FindNodeFunc
- type IAdmin
- type IAdminConnections
- type ImportingSlot
- type MigratingSlot
- type Node
- func (n *Node) Balance() int
- func (n *Node) Clear()
- func (n *Node) GetRole() redisv1alpha1.RedisRole
- func (n *Node) HasStatus(flag string) bool
- func (n *Node) IPPort() string
- func (n *Node) SetBalance(balance int)
- func (n *Node) SetFailureStatus(flags string)
- func (n *Node) SetLinkStatus(status string) error
- func (n *Node) SetReferentMaster(ref string)
- func (n *Node) SetRole(flags string) error
- func (n *Node) String() string
- func (n *Node) ToAPINode() redisv1alpha1.RedisClusterNode
- func (n *Node) TotalSlots() int
- type NodeInfos
- type Nodes
- func (n Nodes) CountByFunc(fn func(*Node) bool) (result int)
- func (n Nodes) FilterByFunc(fn func(*Node) bool) Nodes
- func (n Nodes) GetNodeByID(id string) (*Node, error)
- func (n Nodes) GetNodesByFunc(f FindNodeFunc) (Nodes, error)
- func (n Nodes) Len() int
- func (n Nodes) Less(i, j int) bool
- func (n Nodes) SortByFunc(less func(*Node, *Node) bool) Nodes
- func (n Nodes) SortNodes() Nodes
- func (n Nodes) String() string
- func (n Nodes) Swap(i, j int)
- type RedisFailover
- type RedisReplStatus
- type Slot
- type SlotRange
- type SlotSlice
Constants ¶
const ( // defaultHashMaxSlots higher value of slot // as slots start at 0, total number of slots is defaultHashMaxSlots+1 DefaultHashMaxSlots = 16383 // ResetHard HARD mode for RESET command ResetHard = "HARD" // ResetSoft SOFT mode for RESET command ResetSoft = "SOFT" )
const ( ReplicaStatusUnknown = "unknown" ReplicaStatusReady = "ready" ReplicaStatusNOK = "NOK" ReplicaStatusSyncing = "ReplicaSyncing" ReplicaStatusMasterNil = "ReplicaMasterNil" ClusterStatusMigrating = "SlotsMigrating" )
const ( // ClusterInfosUnset status of the cluster info: no data set ClusterInfosUnset = "Unset" // ClusterInfosPartial status of the cluster info: data is not complete (some nodes didn't respond) ClusterInfosPartial = "Partial" // ClusterInfosInconsistent status of the cluster info: nodesinfos is not consistent between nodes ClusterInfosInconsistent = "Inconsistent" // ClusterInfosConsistent status of the cluster info: nodeinfos is complete and consistent between nodes ClusterInfosConsistent = "Consistent" )
const ( ClusterStateUnknown = "Unknown" ClusterStateNOK = "NOK" ClusterStateOK = "OK" ClusterReasonScaling = "Scaling" ClusterReasonReplicaNOK = "ReplicaNotReady" ClusterStatusFail = "ClusterStatusFail" ClusterStatusNotRetrived = "ClusterStatusNotRetrived" )
const ( // DefaultRedisPort define the default Redis Port DefaultRedisPort = "6379" // RedisMasterRole redis role master RedisMasterRole = "master" // RedisSlaveRole redis role slave RedisSlaveRole = "slave" )
const ( // RedisLinkStateConnected redis connection status connected RedisLinkStateConnected = "connected" // RedisLinkStateDisconnected redis connection status disconnected RedisLinkStateDisconnected = "disconnected" )
const ( // NodeStatusPFail Node is in PFAIL state. Not reachable for the node you are contacting, but still logically reachable NodeStatusPFail = "fail?" // NodeStatusFail Node is in FAIL state. It was not reachable for multiple nodes that promoted the PFAIL state to FAIL NodeStatusFail = "fail" // NodeStatusHandshake Untrusted node, we are handshaking. NodeStatusHandshake = "handshake" // NodeStatusNoAddr No address known for this node NodeStatusNoAddr = "noaddr" // NodeStatusNoFlags no flags at all NodeStatusNoFlags = "noflags" )
const (
// ErrNotFound cannot find a node to connect to
ErrNotFound = "unable to find a node to connect"
)
Variables ¶
var IsMasterWithNoSlot = func(n *Node) bool { if (n.GetRole() == redisv1alpha1.RedisClusterNodeRoleMaster) && (n.TotalSlots() == 0) { return true } return false }
IsMasterWithNoSlot anonymous function for searching Master Node with no slot
var IsMasterWithSlot = func(n *Node) bool { if (n.GetRole() == redisv1alpha1.RedisClusterNodeRoleMaster) && (n.TotalSlots() > 0) { return true } return false }
IsMasterWithSlot anonymous function for searching Master Node withslot
var IsSlave = func(n *Node) bool { return n.GetRole() == redisv1alpha1.RedisClusterNodeRoleSlave }
IsSlave anonymous function for searching Slave Node
Functions ¶
func CheckandUpdateClusterState ¶ added in v0.1.2
func CheckandUpdateClusterState(cinfos *ClusterInfos, cs clusterstate, fromip string, nip string, reason string) error
func DecodeNodeStartTime ¶
DecodeNodeStartTime decode from the cmd output the Redis instance info. Second argument is the node on which we are connected to request info
func DecodeSlotRange ¶
func DecodeSlotRange(str string) ([]Slot, *ImportingSlot, *MigratingSlot, error)
DecodeSlotRange decode from a string a RangeSlot
each entry can have 4 representations: * single slot: ex: 42 * slot range: ex: 42-52 * migrating slot: ex: [42->-67ed2db8d677e59ec4a4cefb06858cf2a1a89fa1] * importing slot: ex: [42-<-67ed2db8d677e59ec4a4cefb06858cf2a1a89fa1]
func IsInconsistentError ¶
IsInconsistentError eturns true if the error is due to cluster inconsistencies
func IsNodeNotFoundedError ¶
IsNodeNotFoundedError returns true if the current error is a NodeNotFoundedError
func IsPartialError ¶
IsPartialError returns true if the error is due to partial data recovery
Types ¶
type Admin ¶
type Admin struct {
// contains filtered or unexported fields
}
Admin wraps redis cluster admin logic
func (*Admin) AttachNodeToCluster ¶
AttachNodeToCluster command use to connect a Node to the cluster
func (*Admin) AttachSlaveToMaster ¶
AttachSlaveToMaster attach a slave to a master node
func (*Admin) ClusterManagerNodeIsEmpty ¶
ClusterManagerNodeIsEmpty Checks whether the node is empty. Node is considered not-empty if it has some key or if it already knows other nodes
func (*Admin) Connections ¶
func (a *Admin) Connections() IAdminConnections
Connections returns the connection map of all clients
func (*Admin) DetachSlave ¶
DetachSlave use to detach a slave to a master
func (*Admin) FailoverSlaveToMaster ¶ added in v0.1.2
FailoverSlaveToMaster manual failover of a slave node to master node
func (*Admin) FlushAndReset ¶
FlushAndReset flush the cluster and reset the cluster configuration of the node. Commands are piped, to ensure no items arrived between flush and reset
func (*Admin) ForgetNode ¶
ForgetNode used to force other redis cluster node to forget a specific node
func (*Admin) GetAllConfig ¶
func (a *Admin) GetAllConfig(ctx context.Context, c *redis.Client, addr string) (map[string]string, error)
GetAllConfig get redis config by CONFIG GET *
func (*Admin) GetClusterInfos ¶
func (a *Admin) GetClusterInfos(ctx context.Context) (*ClusterInfos, error)
GetClusterInfos return the Nodes infos for all nodes
func (*Admin) GetHashMaxSlot ¶
GetHashMaxSlot get the max slot value
func (*Admin) GetSlaveStatus ¶ added in v0.1.2
func (*Admin) MigrateKeys ¶
func (a *Admin) MigrateKeys(ctx context.Context, addr string, dest *Node, slots []Slot, batch int, timeout int, replace bool) (int, error)
MigrateKeys use to migrate keys from slots to other slots. if replace is true, replace key on busy error timeout is in milliseconds
func (*Admin) MigrateKeysInSlot ¶
func (a *Admin) MigrateKeysInSlot(ctx context.Context, addr string, dest *Node, slot Slot, batch int, timeout int, replace bool) (int, error)
MigrateKeys use to migrate keys from slot to other slot. if replace is true, replace key on busy error timeout is in milliseconds
func (*Admin) ResetPassword ¶
ResetPassword reset redis node masterauth and requirepass.
func (*Admin) SetConfigIfNeed ¶
SetConfigIfNeed set redis config
type AdminConnections ¶
type AdminConnections struct {
// contains filtered or unexported fields
}
AdminConnections connection map for redis cluster currently the admin connection is not threadSafe since it is only use in the Events thread.
func (*AdminConnections) Add ¶
func (cnx *AdminConnections) Add(ctx context.Context, addr string) error
Add connect to the given address and register the client connection to the map
func (*AdminConnections) AddAll ¶
func (cnx *AdminConnections) AddAll(ctx context.Context, addrs []string)
AddAll connect to the given list of addresses and register them in the map fail silently
func (*AdminConnections) Close ¶
func (cnx *AdminConnections) Close(ctx context.Context)
Close used to close all possible resources instanciate by the Connections
func (*AdminConnections) Get ¶
Get returns a client connection for the given adress, connects if the connection is not in the map yet
func (*AdminConnections) GetAUTH ¶
func (cnx *AdminConnections) GetAUTH() (string, bool)
GetAUTH return password and true if connection password is set, else return false.
func (*AdminConnections) GetAll ¶
func (cnx *AdminConnections) GetAll() map[string]*redis.Client
GetAll returns a map of all clients per address
func (*AdminConnections) GetDifferentFrom ¶
func (cnx *AdminConnections) GetDifferentFrom(addr string) (*redis.Client, error)
GetDifferentFrom returns random a client connection different from given address
func (*AdminConnections) GetRandom ¶
func (cnx *AdminConnections) GetRandom() (*redis.Client, error)
GetRandom returns a client connection to a random node of the client map
func (*AdminConnections) GetSelected ¶
func (cnx *AdminConnections) GetSelected(addrs []string) map[string]*redis.Client
GetSelected returns a map of clients based on the input addresses
func (*AdminConnections) Reconnect ¶
func (cnx *AdminConnections) Reconnect(ctx context.Context, addr string) error
Reconnect force a reconnection on the given address is the adress is not part of the map, act like Add
func (*AdminConnections) Remove ¶
func (cnx *AdminConnections) Remove(ctx context.Context, addr string)
Remove disconnect and remove the client connection from the map
func (*AdminConnections) ReplaceAll ¶
func (cnx *AdminConnections) ReplaceAll(ctx context.Context, addrs []string)
ReplaceAll clear the pool and re-populate it with new connections fail silently
func (*AdminConnections) Reset ¶
func (cnx *AdminConnections) Reset(ctx context.Context)
Reset close all connections and clear the connection map
func (*AdminConnections) Update ¶
Update returns a client connection for the given adress, connects if the connection is not in the map yet
func (*AdminConnections) ValidatePipeResp ¶
func (cnx *AdminConnections) ValidatePipeResp(ctx context.Context, resp []redis.Cmder, addr string, err error, errMessage string) bool
// ValidatePipeResp wait for all answers in the pipe and validate the response // in case of network issue clear the pipe and return // in case of error, return false
func (*AdminConnections) ValidateResp ¶
func (cnx *AdminConnections) ValidateResp(ctx context.Context, resp *redis.Cmd, addr, errMessage string) error
// ValidateResp check the redis resp, eventually reconnect on connection error // in case of error, customize the error, log it and return it
type AdminOptions ¶
type AdminOptions struct { ConnectionTimeout time.Duration ClientName string RenameCommandsFile string Password string }
AdminOptions optional options for redis admin
type Cluster ¶
type Cluster struct { Name string Namespace string Nodes map[string]*Node Status redisv1alpha1.ClusterStatus NodesPlacement redisv1alpha1.NodesPlacementInfo ActionsInfo ClusterActionsInfo HaStatus redisv1alpha1.HaStatus }
Cluster represents a Redis Cluster
func NewCluster ¶
NewCluster builds and returns new Cluster instance
func (*Cluster) AddNode ¶
AddNode used to add new Node in the cluster if node with the same ID is already present in the cluster the previous Node is replaced
func (*Cluster) GetNodeByFunc ¶
func (c *Cluster) GetNodeByFunc(f FindNodeFunc) (*Node, error)
GetNodeByFunc returns first node found by the FindNodeFunc
func (*Cluster) GetNodeByID ¶
GetNodeByID returns a Cluster Node by its ID if not present in the cluster return an error
func (*Cluster) GetNodeByIP ¶
GetNodeByIP returns a Cluster Node by its ID if not present in the cluster return an error
func (*Cluster) GetNodeByPodName ¶
GetNodeByPodName returns a Cluster Node by its Pod name if not present in the cluster return an error
func (*Cluster) GetNodesByFunc ¶
func (c *Cluster) GetNodesByFunc(f FindNodeFunc) (Nodes, error)
GetNodesByFunc returns first node found by the FindNodeFunc
type ClusterActionsInfo ¶
type ClusterActionsInfo struct {
NbslotsToMigrate int32
}
ClusterActionsInfo use to store information about current action on the Cluster
type ClusterInfos ¶
type ClusterInfos struct { Infos map[string]*NodeInfos Status string ClusterState clusterstate ClusterNokReason map[string]string }
ClusterInfos represents the node infos for all nodes of the cluster
func NewClusterInfos ¶
func NewClusterInfos() *ClusterInfos
NewClusterInfos returns an instance of ClusterInfos
func (*ClusterInfos) ComputeStatus ¶
func (c *ClusterInfos) ComputeStatus(log logr.Logger) bool
ComputeStatus check the ClusterInfos status based on the current data the status ClusterInfosPartial is set while building the clusterinfos if already set, do nothing returns true if contistent or if another error
func (*ClusterInfos) GetNodes ¶
func (c *ClusterInfos) GetNodes() Nodes
GetNodes returns a nodeSlice view of the cluster the slice if formed from how each node see itself you should check the Status before doing it, to wait for a consistent view
type ClusterInfosError ¶
type ClusterInfosError struct {
// contains filtered or unexported fields
}
ClusterInfosError error type for redis cluster infos access
func NewClusterInfosError ¶
func NewClusterInfosError() ClusterInfosError
NewClusterInfosError returns an instance of cluster infos error
func (ClusterInfosError) Inconsistent ¶
func (e ClusterInfosError) Inconsistent() bool
Inconsistent true if the nodes do not agree with each other
func (ClusterInfosError) Partial ¶
func (e ClusterInfosError) Partial() bool
Partial true if the some nodes of the cluster didn't answer
type ConfigSignature ¶
ConfigSignature Represents the slots of each node
func (ConfigSignature) String ¶
func (c ConfigSignature) String() string
String representation of a ConfigSignaure
type FindNodeFunc ¶
FindNodeFunc function for finding a Node it is use as input for GetNodeByFunc and GetNodesByFunc
type IAdmin ¶
type IAdmin interface { // Connections returns the connection map of all clients Connections() IAdminConnections // Close the admin connections Close(ctx context.Context) // GetClusterInfos get node infos for all nodes GetClusterInfos(ctx context.Context) (*ClusterInfos, error) // ClusterManagerNodeIsEmpty Checks whether the node is empty. Node is considered not-empty if it has // some key or if it already knows other nodes ClusterManagerNodeIsEmpty(ctx context.Context) (bool, error) // SetConfigEpoch Assign a different config epoch to each node SetConfigEpoch(ctx context.Context) error // SetConfigIfNeed set redis config SetConfigIfNeed(ctx context.Context, newConfig map[string]string) error // GetAllConfig get redis config by CONFIG GET * GetAllConfig(ctx context.Context, c *redis.Client, addr string) (map[string]string, error) // AttachNodeToCluster command use to connect a Node to the cluster // the connection will be done on a random node part of the connection pool AttachNodeToCluster(ctx context.Context, addr string) error // AttachSlaveToMaster attach a slave to a master node AttachSlaveToMaster(ctx context.Context, slave *Node, masterID string) error // DetachSlave dettach a slave to its master DetachSlave(ctx context.Context, slave *Node) error // ForgetNode execute the Redis command to force the cluster to forgot the the Node ForgetNode(ctx context.Context, id string) error // SetSlots exec the redis command to set slots in a pipeline, provide // and empty nodeID if the set slots commands doesn't take a nodeID in parameter SetSlots(ctx context.Context, addr string, action string, slots []Slot, nodeID string) error // AddSlots exec the redis command to add slots in a pipeline AddSlots(ctx context.Context, addr string, slots []Slot) error // SetSlot use to set SETSLOT command on a slot SetSlot(ctx context.Context, addr string, action string, slot Slot, nodeID string) error // MigrateKeys from addr to destination node. returns number of slot migrated. If replace is true, replace key on busy error MigrateKeys(ctx context.Context, addr string, dest *Node, slots []Slot, batch, timeout int, replace bool) (int, error) // MigrateKeys use to migrate keys from slot to other slot. if replace is true, replace key on busy error // timeout is in milliseconds MigrateKeysInSlot(ctx context.Context, addr string, dest *Node, slot Slot, batch int, timeout int, replace bool) (int, error) // FlushAndReset reset the cluster configuration of the node, the node is flushed in the same pipe to ensure reset works FlushAndReset(ctx context.Context, addr string, mode string) error // GetHashMaxSlot get the max slot value GetHashMaxSlot() Slot // ResetPassword reset redis node masterauth and requirepass. ResetPassword(ctx context.Context, newPassword string) error FailoverSlaveToMaster(ctx context.Context, slave *Node, option RedisFailover) error }
IAdmin redis cluster admin interface
type IAdminConnections ¶
type IAdminConnections interface { // Add connect to the given address and // register the client connection to the pool Add(ctx context.Context, addr string) error // Remove disconnect and remove the client connection from the map Remove(ctx context.Context, addr string) // Get returns a client connection for the given address, // connects if the connection is not in the map yet Get(ctx context.Context, addr string) (*redis.Client, error) // GetRandom returns a client connection to a random node of the client map GetRandom() (*redis.Client, error) // GetDifferentFrom returns a random client connection different from given address GetDifferentFrom(addr string) (*redis.Client, error) // GetAll returns a map of all clients per address GetAll() map[string]*redis.Client //GetSelected returns a map of clients based on the input addresses GetSelected(addrs []string) map[string]*redis.Client // Reconnect force a reconnection on the given address // if the adress is not part of the map, act like Add Reconnect(ctx context.Context, addr string) error // AddAll connect to the given list of addresses and // register them in the map // fail silently AddAll(ctx context.Context, addrs []string) // ReplaceAll clear the map and re-populate it with new connections // fail silently ReplaceAll(ctx context.Context, addrs []string) // ValidateResp check the redis resp, eventually reconnect on connection error // in case of error, customize the error, log it and return it ValidateResp(ctx context.Context, resp *redis.Cmd, addr, errMessage string) error // ValidatePipeResp wait for all answers in the pipe and validate the response // in case of network issue clear the pipe and return // in case of error return false ValidatePipeResp(ctx context.Context, resp []redis.Cmder, addr string, err error, errMessage string) bool // Reset close all connections and clear the connection map Reset(ctx context.Context) // GetAUTH return password and true if connection password is set, else return false. GetAUTH() (string, bool) }
IAdminConnections interface representing the map of admin connections to redis cluster nodes
func NewAdminConnections ¶
func NewAdminConnections(addrs []string, options *AdminOptions, log logr.Logger, ctx context.Context) IAdminConnections
NewAdminConnections returns and instance of AdminConnectionsInterface
type ImportingSlot ¶
ImportingSlot represents an importing slot (slot + importing from node id)
func (ImportingSlot) String ¶
func (s ImportingSlot) String() string
String string representation of an importing slot
type MigratingSlot ¶
MigratingSlot represents a migrating slot (slot + migrating to node id)
func (MigratingSlot) String ¶
func (s MigratingSlot) String() string
String string representation of a migratting slot
type Node ¶
type Node struct { ID string IP string Port string Role string LinkState string MasterReferent string FailStatus []string PingSent int64 PongRecv int64 ConfigEpoch int64 Slots []Slot MigratingSlots map[Slot]string ImportingSlots map[Slot]string ServerStartTime time.Time NodeName string Zonename string PodName string StatefulSet string // contains filtered or unexported fields }
Node Represent a Redis Node
func NewDefaultNode ¶
func NewDefaultNode() *Node
NewDefaultNode builds and returns new defaultNode instance
func (*Node) Clear ¶
func (n *Node) Clear()
Clear used to clear possible ressources attach to the current Node
func (*Node) GetRole ¶
func (n *Node) GetRole() redisv1alpha1.RedisRole
GetRole return the Redis Cluster Node GetRole
func (*Node) SetBalance ¶
func (*Node) SetFailureStatus ¶
SetFailureStatus set from inputs flags the possible failure status
func (*Node) SetLinkStatus ¶
SetLinkStatus set the Node link status
func (*Node) SetReferentMaster ¶
SetReferentMaster set the redis node parent referent
func (*Node) ToAPINode ¶
func (n *Node) ToAPINode() redisv1alpha1.RedisClusterNode
ToAPINode used to convert the current Node to an API redisv1alpha1.RedisClusterNode
func (*Node) TotalSlots ¶
TotalSlots return the total number of slot
type NodeInfos ¶
NodeInfos representation of a node info, i.e. data returned by the CLUSTER NODE redis command Node is the information of the targetted node Friends are the view of the other nodes from the targetted node
func DecodeNodeInfos ¶
DecodeNodeInfos decode from the cmd output the Redis nodes info. Second argument is the node on which we are connected to request info
type Nodes ¶
type Nodes []*Node
Nodes represent a Node slice
func (Nodes) CountByFunc ¶
CountByFunc gives the number elements of NodeSlice that return true for the passed func.
func (Nodes) FilterByFunc ¶
FilterByFunc remove a node from a slice by node ID and returns the slice. If not found, fail silently. Value must be unique
func (Nodes) GetNodeByID ¶
GetNodeByID returns a Redis Node by its ID if not present in the Nodes slice return an error
func (Nodes) GetNodesByFunc ¶
func (n Nodes) GetNodesByFunc(f FindNodeFunc) (Nodes, error)
GetNodesByFunc returns first node found by the FindNodeFunc
func (Nodes) Less ¶
Less reports whether the element with index i should sort before the element with index j.
func (Nodes) SortByFunc ¶
SortByFunc returns a new ordered NodeSlice, determined by a func defining ‘less’.
type RedisFailover ¶ added in v0.1.2
type RedisFailover string
const ( RedisFailoverForce RedisFailover = "FORCE" RedisFailoverTakeover RedisFailover = "TAKEOVER" RedisFailoverDefault RedisFailover = "" )
type RedisReplStatus ¶ added in v0.1.2
type RedisReplStatus string
Redis Status Redis server status
const ( // RedisSyncing Redis server syncing in in progress with master RedisSyncing RedisReplStatus = "master_sync_in_progress:1" RedisMasterSillPending RedisReplStatus = "master_host:127.0.0.1" RedisLinkUp RedisReplStatus = "master_link_status:up" )
type Slot ¶
type Slot uint64
Slot represent a Redis Cluster slot
func AddSlots ¶
AddSlots return a new list of slots after adding some slots in it, duplicates are removed
func BuildSlotSlice ¶
BuildSlotSlice return a slice of all slots between this range
func DecodeSlot ¶
DecodeSlot parse a string representation of a slot slot
func RemoveSlot ¶
RemoveSlot return a new list of slot where a specified slot have been removed.
func RemoveSlots ¶
RemoveSlots return a new list of slot where a list of slots have been removed, doesn't work if duplicates
type SlotRange ¶
SlotRange represent a Range of slots
func SlotRangesFromSlots ¶
SlotRangesFromSlots return a slice of slot ranges from a slice of slots