redis

package
v0.0.0-...-3430a5a Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MinTLSSupportedVersion, _  = semver.NewVersion("6.0-AAA")
	MinACLSupportedVersion     = MinTLSSupportedVersion
	MinACL2SupportedVersion, _ = semver.NewVersion("7.0-AAA")
)

Functions

func NewRedisRole

func NewRedisRole(v string) core.RedisRole

Types

type RedisArch

type RedisArch = core.Arch

type RedisNode

type RedisNode 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 accessable
	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 redis server version
	// this value maybe differ with cr def when do version upgrade
	CurrentVersion() RedisVersion

	// 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 redis server, the role is master when in cluster mode
	Role() core.RedisRole
	// 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) (interface{}, error)
	Query(ctx context.Context, cmd string, args ...any) (any, error)
	Info() rediscli.RedisInfo
	ClusterInfo() rediscli.RedisClusterInfo

	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
}

RedisNode

type RedisSentinelNode

type RedisSentinelNode interface {
	metav1.Object
	RedisSentinelNodeOperation
	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
}

RedisSentinelNode

type RedisSentinelNodeOperation

type RedisSentinelNodeOperation interface {
	// CurrentVersion return current redis server version
	// this value maybe differ with cr def when do version upgrade
	CurrentVersion() RedisVersion

	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() rediscli.RedisInfo
	// sentinel inspect
	Brothers(ctx context.Context, name string) ([]*rediscli.SentinelMonitorNode, error)
	MonitoringClusters(ctx context.Context) (clusters []string, err error)
	MonitoringNodes(ctx context.Context, name string) (master *rediscli.SentinelMonitorNode, replicas []*rediscli.SentinelMonitorNode, err error)
}

type RedisVersion

type RedisVersion string

RedisVersion

const (
	// RedisVersionUnknown
	RedisVersionUnknown RedisVersion = ""
	// RedisVersion4
	RedisVersion4 RedisVersion = "4.0"
	// RedisVersion5
	RedisVersion5 RedisVersion = "5.0"
	// RedisVersion6, Supports ACL, io-threads
	RedisVersion6 RedisVersion = "6.0"
	// RedisVersion6_2
	RedisVersion6_2 RedisVersion = "6.2"
	// RedisVersion7
	RedisVersion7 RedisVersion = "7.0"
	// Supports ACL2, Function
	RedisVersion7_2 RedisVersion = "7.2"
	// Supports modules
	ActiveRedisVersion6 RedisVersion = "6.0"
)

func ParseRedisVersion

func ParseRedisVersion(v string) (RedisVersion, error)

ParseVersion

func ParseRedisVersionFromImage

func ParseRedisVersionFromImage(u string) (RedisVersion, error)

ParseRedisVersionFromImage

func (RedisVersion) CustomConfigs

func (v RedisVersion) CustomConfigs(arch RedisArch) map[string]string

func (RedisVersion) IsACL2Supported

func (v RedisVersion) IsACL2Supported() bool

func (RedisVersion) IsACLSupported

func (v RedisVersion) IsACLSupported() bool

func (RedisVersion) IsClusterShardSupported

func (v RedisVersion) IsClusterShardSupported() bool

func (RedisVersion) IsTLSSupported

func (v RedisVersion) IsTLSSupported() bool

func (RedisVersion) String

func (v RedisVersion) String() string

Jump to

Keyboard shortcuts

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