types

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNodeRole

func NewNodeRole(v string) core.NodeRole

func NewOperatorUser

func NewOperatorUser(secret *v1.Secret) (*user.User, error)

NewOperatorUser

func NewSentinelUser

func NewSentinelUser(name string, role user.UserRole, secret *v1.Secret) (*user.User, error)

NewSentinelUser

func NewUserFromValkeyUser

func NewUserFromValkeyUser(username, ruleStr string, pwd *user.Password) (*user.User, error)

func PatchClusterClientRequiredRules

func PatchClusterClientRequiredRules(rule *user.Rule) *user.Rule

Patch Valkey cluster client required rules

func PatchPubsubRules

func PatchPubsubRules(rule *user.Rule) *user.Rule

Types

type ClusterInstance

type ClusterInstance interface {
	Instance

	Definition() *v1alpha1.Cluster
	Status() *v1alpha1.ClusterStatus

	Masters() []ValkeyNode
	Nodes() []ValkeyNode
	RawNodes(ctx context.Context) ([]corev1.Pod, error)
	Shards() []ClusterShard
	RewriteShards(ctx context.Context, shards []*v1alpha1.ClusterShards) error
}

Instance

type ClusterShard

type ClusterShard interface {
	Object

	Definition() *appv1.StatefulSet
	Status() *appv1.StatefulSetStatus

	Index() int
	Nodes() []ValkeyNode
	// Master returns the master node of this shard which has joined the cluster
	// Keep in mind that, this not means the master has been assigned slots
	Master() ValkeyNode
	// Replicas returns nodes whoses role is slave
	Replicas() []ValkeyNode

	// Slots returns the slots of this shard
	Slots() *slot.Slots
	IsImporting() bool
	IsMigrating() bool
}

ClusterShard

type FailoverInstance

type FailoverInstance interface {
	Instance

	Definition() *v1alpha1.Failover
	Masters() []ValkeyNode
	Nodes() []ValkeyNode
	RawNodes(ctx context.Context) ([]corev1.Pod, error)
	Monitor() FailoverMonitor

	IsBindedSentinel() bool
	IsStandalone() bool
	Selector() map[string]string
}

type FailoverMonitor

type FailoverMonitor interface {
	Policy() v1alpha1.FailoverPolicy
	Master(ctx context.Context, flags ...bool) (*valkey.SentinelMonitorNode, error)
	Replicas(ctx context.Context) ([]*valkey.SentinelMonitorNode, error)
	Inited(ctx context.Context) (bool, error)
	AllNodeMonitored(ctx context.Context) (bool, error)
	UpdateConfig(ctx context.Context, params map[string]string) error
	Failover(ctx context.Context) error
	Monitor(ctx context.Context, node ValkeyNode) error
	Reset(ctx context.Context) error
}

type Instance

type Instance interface {
	Object

	Arch() core.Arch
	// Issuer custom cert issuer
	Issuer() *certmetav1.ObjectReference
	Users() Users
	TLSConfig() *tls.Config
	IsInService() bool
	IsACLUserExists() bool
	// TODO: deprecated
	IsACLAppliedToAll() bool
	IsResourceFullfilled(ctx context.Context) (bool, error)
	UpdateStatus(ctx context.Context, st InstanceStatus, message string) error
	SendEventf(eventtype, reason, messageFmt string, args ...any)
	Logger() logr.Logger
}

type InstanceStatus

type InstanceStatus string
const (
	Any    InstanceStatus = ""
	OK     InstanceStatus = "OK"
	Fail   InstanceStatus = "Fail"
	Paused InstanceStatus = "Paused"
)

type Object

type Object interface {
	v1.Object
	GetObjectKind() schema.ObjectKind
	DeepCopyObject() runtime.Object
	NamespacedName() client.ObjectKey
	Version() version.ValkeyVersion
	IsReady() bool

	Restart(ctx context.Context, annotationKeyVal ...string) error
	Refresh(ctx context.Context) error
}

type Replication

type Replication interface {
	Object

	Definition() *appv1.StatefulSet
	Status() *appv1.StatefulSetStatus

	// Master returns the master node of this shard which has joined the cluster
	// Keep in mind that, this not means the master has been assigned slots
	Master() ValkeyNode
	// Replicas returns nodes whoses role is slave
	Replicas() []ValkeyNode
	Nodes() []ValkeyNode
}

type Sentinel

type Sentinel interface {
	Object

	Definition() *appv1.Deployment
	Status() *appv1.DeploymentStatus

	Nodes() []SentinelNode
}

type SentinelInstance

type SentinelInstance interface {
	Instance

	Definition() *v1alpha1.Sentinel
	Replication() SentinelReplication
	Nodes() []SentinelNode
	RawNodes(ctx context.Context) ([]corev1.Pod, error)
	// Clusters returns the clusters which this sentinel is monitoring
	Clusters(ctx context.Context) ([]string, error)

	// helper methods
	GetPassword() (string, error)

	Selector() map[string]string
}

type SentinelNode

type SentinelNode interface {
	metav1.Object
	SentinelNodeOperation
	GetObjectKind() schema.ObjectKind

	Definition() *corev1.Pod

	// Index the index of statefulset
	Index() int
	// IsTerminating indicate whether is pod is deleted
	IsTerminating() bool
	// IsReady indicate whether is main container is ready
	IsReady() bool
	// IsACLApplied returns true when the main container got ACL_CONFIGMAP_NAME env
	IsACLApplied() bool

	Port() int
	InternalPort() int
	DefaultIP() net.IP
	DefaultInternalIP() net.IP
	IPs() []net.IP
	NodeIP() net.IP

	Status() corev1.PodPhase
	ContainerStatus() *corev1.ContainerStatus
}

SentinelNode

type SentinelNodeOperation

type SentinelNodeOperation interface {
	// CurrentVersion return current valkey server version
	// this value maybe differ with cr def when do version upgrade
	CurrentVersion() version.ValkeyVersion

	Refresh(ctx context.Context) error

	Config() map[string]string

	// Setup
	Setup(ctx context.Context, margs ...[]any) error
	SetMonitor(ctx context.Context, name, ip, port, user, password, quorum string) error
	Query(ctx context.Context, cmd string, args ...any) (any, error)
	Info() vkcli.NodeInfo
	// sentinel inspect
	Brothers(ctx context.Context, name string) ([]*vkcli.SentinelMonitorNode, error)
	MonitoringClusters(ctx context.Context) (clusters []string, err error)
	MonitoringNodes(ctx context.Context, name string) (master *vkcli.SentinelMonitorNode, replicas []*vkcli.SentinelMonitorNode, err error)
}

type SentinelReplication

type SentinelReplication interface {
	Object

	Definition() *appv1.StatefulSet
	Status() *appv1.StatefulSetStatus

	Nodes() []SentinelNode
}

type Users

type Users []*core.User

Users

func (Users) Encode

func (us Users) Encode(patch bool) map[string]string

Encode

func (Users) GetDefaultUser

func (us Users) GetDefaultUser() *core.User

GetDefaultUser

func (Users) GetOpUser

func (us Users) GetOpUser() *core.User

GetByRole

func (Users) IsChanged

func (us Users) IsChanged(n Users) bool

IsChanged

type ValkeyNode

type ValkeyNode interface {
	GetObjectKind() schema.ObjectKind
	metav1.Object

	Definition() *corev1.Pod

	// ID returns cluster node id
	ID() string
	// Index the index of statefulset
	Index() int
	// IsConnected indicate where this node is accessible
	IsConnected() bool
	// IsTerminating indicate whether is pod is deleted
	IsTerminating() bool
	// IsMasterLinkUp indicate whether the master link is up
	IsMasterLinkUp() bool
	// IsReady indicate whether is main container is ready
	IsReady() bool
	// IsJoined will indicate whether this node has joined with other nodes.
	// be sure that, this can't indicate that all pods has joined
	IsJoined() bool
	// MasterID if this node is a slave, return master id it replica to
	MasterID() string
	// IsMasterFailed returns where the master is failed. if itself is master, this func will always return false
	IsMasterFailed() bool
	// CurrentVersion return current valkey server version
	// this value maybe differ with cr def when do version upgrade
	CurrentVersion() version.ValkeyVersion

	// IsACLApplied returns true when the main container got ACL_CONFIGMAP_NAME env
	IsACLApplied() bool

	// Role returns the role of current node
	// be sure that for the new start valkey server, the role is master when in cluster mode
	Role() core.NodeRole
	// Slots if this node is master, returns the slots this nodes assigned
	// else returns nil
	Slots() *slot.Slots

	Config() map[string]string
	ConfigedMasterIP() string
	ConfigedMasterPort() string
	// Setup
	Setup(ctx context.Context, margs ...[]any) error
	ReplicaOf(ctx context.Context, ip, port string) error
	SetACLUser(ctx context.Context, username string, passwords []string, rules string) (any, error)
	Query(ctx context.Context, cmd string, args ...any) (any, error)
	Info() vkcli.NodeInfo
	ClusterInfo() vkcli.ClusterNodeInfo

	IPort() int
	InternalIPort() int
	Port() int
	InternalPort() int
	DefaultIP() net.IP
	DefaultInternalIP() net.IP
	IPs() []net.IP
	NodeIP() net.IP

	Status() corev1.PodPhase
	ContainerStatus() *corev1.ContainerStatus

	Refresh(ctx context.Context) error
}

ValkeyNode

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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