redis

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RedisServer

type RedisServer struct {
	Name string
	Host string
	Port string
	Role client.Role
	CRUD *crud.CRUD
}

RedisServer represent a redis server and its characteristics

func NewRedisServerFromConnectionString

func NewRedisServerFromConnectionString(name, connectionString string) (*RedisServer, error)

func (*RedisServer) Cleanup added in v0.14.0

func (srv *RedisServer) Cleanup(log logr.Logger) error

Cleanup closes all Redis clients opened during the RedisServer object creation

func (*RedisServer) Discover

func (srv *RedisServer) Discover(ctx context.Context) error

Discover returns the Role for a given redis Server

func (*RedisServer) IP

func (rs *RedisServer) IP() (string, error)

type SentinelPool

type SentinelPool []SentinelServer

SentinelPool represents a pool of SentinelServers that monitor the same group of redis shards

func NewSentinelPool

func NewSentinelPool(ctx context.Context, cl client.Client, key types.NamespacedName, replicas int) (SentinelPool, error)

NewSentinelPool creates a new SentinelPool object given a key and a number of replicas by calling the k8s API to discover sentinel Pods. The kye es the Name/Namespace of the StatefulSet that owns the sentinel Pods.

func (SentinelPool) Cleanup added in v0.14.0

func (sp SentinelPool) Cleanup(log logr.Logger) []error

Cleanup closes all Redis clients opened during the SentinelPool object creation

func (SentinelPool) IsMonitoringShards

func (sp SentinelPool) IsMonitoringShards(ctx context.Context, shards []string) (bool, error)

IsMonitoringShards checks whether or all the shards in the passed list are being monitored by all sentinel servers in the SentinelPool

func (SentinelPool) Monitor

func (sp SentinelPool) Monitor(ctx context.Context, shards ShardedCluster) (map[string][]string, error)

Monitor ensures that all the shards in the ShardedCluster object are monitored by all sentinel servers in the SentinelPool

func (SentinelPool) MonitoredShards added in v0.13.0

func (sp SentinelPool) MonitoredShards(ctx context.Context, quorum int, options ...ShardDiscoveryOption) (saasv1alpha1.MonitoredShards, error)

MonitoredShards returns the list of monitored shards of this SentinelServer

type SentinelServer

type SentinelServer struct {
	Name                  string
	IP                    string
	Port                  string
	CRUD                  *crud.CRUD
	MonitoredRedisServers map[string]*RedisServer
}

SentinelServer represents a sentinel Pod

func NewSentinelServerFromConnectionString

func NewSentinelServerFromConnectionString(name, connectionString string) (*SentinelServer, error)

func (*SentinelServer) Cleanup added in v0.14.0

func (ss *SentinelServer) Cleanup(log logr.Logger) error

Cleanup closes all Redis clients opened during the SentinelServer object creation

func (*SentinelServer) DiscoverShard added in v0.16.1

func (ss *SentinelServer) DiscoverShard(ctx context.Context, shard string, maxInfoCacheAge time.Duration,
	opts ShardDiscoveryOptions) (map[string]saasv1alpha1.RedisServerDetails, error)

func (*SentinelServer) IsMonitoringShards

func (ss *SentinelServer) IsMonitoringShards(ctx context.Context, shards []string) (bool, error)

IsMonitoringShards checks whether or all the shards in the passed list are being monitored by the SentinelServer

func (*SentinelServer) Monitor

func (ss *SentinelServer) Monitor(ctx context.Context, shards ShardedCluster) ([]string, error)

Monitor ensures that all the shards in the ShardedCluster object are monitored by the SentinelServer

func (*SentinelServer) MonitoredShards added in v0.13.0

func (ss *SentinelServer) MonitoredShards(ctx context.Context, options ...ShardDiscoveryOption) (saasv1alpha1.MonitoredShards, error)

MonitoredShards returns the list of monitored shards of this SentinelServer

func (*SentinelServer) OpenDirectRedisConnection added in v0.16.1

func (ss *SentinelServer) OpenDirectRedisConnection(ctx context.Context, ip string, port int) (*RedisServer, error)

type Shard

type Shard struct {
	Name    string
	Servers []RedisServer
}

Shard is a list of the redis Server objects that compose a redis shard

func NewShard

func NewShard(name string, connectionStrings []string) (*Shard, error)

NewShard returns a Shard object given the passed redis server URLs

func (*Shard) Cleanup added in v0.14.0

func (s *Shard) Cleanup(log logr.Logger) []error

Cleanup closes all Redis clients opened during the Shard object creation

func (*Shard) Discover

func (s *Shard) Discover(ctx context.Context, log logr.Logger) error

Discover retrieves the role and read-only flag for all the servers in the shard

func (*Shard) GetMasterAddr

func (s *Shard) GetMasterAddr() (string, string, error)

GetMasterAddr returns the URL of the master server in a shard or error if zero or more than one master is found

func (*Shard) Init

func (s *Shard) Init(ctx context.Context, masterIndex int32, log logr.Logger) ([]string, error)

Init initializes this shard if not already initialized

type ShardDiscoveryOption added in v0.16.1

type ShardDiscoveryOption int
const (
	OnlyMasterDiscoveryOpt ShardDiscoveryOption = iota
	SlaveReadOnlyDiscoveryOpt
	SaveConfigDiscoveryOpt
)

type ShardDiscoveryOptions added in v0.16.1

type ShardDiscoveryOptions []ShardDiscoveryOption

func (ShardDiscoveryOptions) Has added in v0.16.1

type ShardedCluster

type ShardedCluster []Shard

ShardedCluster represents a sharded redis cluster, composed by several Shards

func NewShardedCluster

func NewShardedCluster(ctx context.Context, serverList map[string][]string, log logr.Logger) (ShardedCluster, error)

NewShardedCluster returns a new ShardedCluster given the shard structure passed as a map[string][]string

func (ShardedCluster) Cleanup added in v0.14.0

func (sc ShardedCluster) Cleanup(log logr.Logger) []error

Cleanup closes all Redis clients opened during the ShardedCluster object creation

func (ShardedCluster) Discover

func (sc ShardedCluster) Discover(ctx context.Context, log logr.Logger) error

func (ShardedCluster) GetShardByName

func (sc ShardedCluster) GetShardByName(name string) *Shard

func (ShardedCluster) GetShardNames

func (sc ShardedCluster) GetShardNames() []string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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