redis

package
v0.0.0-...-0227cab Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RedisVersionUnknown
	RedisVersionUnknown RedisVersion = ""
	// RedisVersion4
	RedisVersion4 = "4.0"
	// RedisVersion5
	RedisVersion5 = "5.0"
	// RedisVersion6
	//
	// Supports ACL, io-threads
	RedisVersion6 = "6.0"
	// RedisVersion6_2
	RedisVersion6_2 = "6.2"

	// Supports ACL2, Function
	// RedisVersion7
	RedisVersion7   = "7.0"
	RedisVersion7_2 = "7.2"
)

Variables

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

Functions

This section is empty.

Types

type RedisArch

type RedisArch string
const (
	StandaloneArch RedisArch = "standalone"
	SentinelArch   RedisArch = "sentinel"
	ClusterArch    RedisArch = "cluster"
)

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() RedisRole
	// Slots if this node is master, returns the slots this nodes assigned
	// else returns nil
	Slots() *slot.Slots

	GetPod() *corev1.Pod
	Config() map[string]string
	ConfigedMasterIP() string
	ConfigedMasterPort() string
	// Setup
	Setup(ctx context.Context, margs ...[]any) error
	SetMonitor(ctx context.Context, ip, port, user, password, quorum string) 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

	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 RedisRole

type RedisRole string

RedisRole redis node role type

const (
	// RedisRoleMaster RedisCluster Master node role
	RedisRoleMaster RedisRole = "Master"
	// RedisRoleSlave RedisCluster Master node role
	RedisRoleSlave RedisRole = "Slave"
	// RedisNodeRoleNone None node role
	RedisRoleNone RedisRole = "None"
)

func NewRedisRole

func NewRedisRole(v string) RedisRole

type RedisVersion

type RedisVersion string

RedisVersion

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

func (v RedisVersion) IsTLSSupported() bool

type SentinelRole

type SentinelRole string
const (
	SentinelRoleMaster   SentinelRole = "master"
	SentinelRoleSlave    SentinelRole = "slave"
	SentinelRoleSentinel SentinelRole = "sentinel"
)

Jump to

Keyboard shortcuts

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