sharded

package
v0.22.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	Shards    []*Shard
	Sentinels []*SentinelServer
	// contains filtered or unexported fields
}

Cluster represents a sharded redis cluster, composed by several Shards

func NewShardedCluster

func NewShardedCluster(ctx context.Context, pool *redis.ServerPool, sentinels map[string]string, shards ...*Shard) (*Cluster, error)

func NewShardedClusterFromTopology

func NewShardedClusterFromTopology(ctx context.Context, serverList map[string]map[string]string, pool *redis.ServerPool) (*Cluster, error)

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

func (*Cluster) Discover

func (cluster *Cluster) Discover(ctx context.Context, options ...DiscoveryOption) error

func (*Cluster) GetSentinel

func (cluster *Cluster) GetSentinel(pctx context.Context) *SentinelServer

GetSentinel returns a healthy SentinelServer from the list of sentinels Returns nil if no healthy SentinelServer was found

func (*Cluster) GetShardNames

func (cluster *Cluster) GetShardNames() []string

func (Cluster) LookupServerByID

func (cluster Cluster) LookupServerByID(hostport string) *RedisServer

func (Cluster) LookupShardByName

func (cluster Cluster) LookupShardByName(name string) *Shard

func (*Cluster) SentinelDiscover

func (cluster *Cluster) SentinelDiscover(ctx context.Context, opts ...DiscoveryOption) error

Updates the status of the cluster as seen from sentinel

type DiscoveryError_Master_SingleServerFailure

type DiscoveryError_Master_SingleServerFailure struct {
	// contains filtered or unexported fields
}

type DiscoveryError_Sentinel_Failure

type DiscoveryError_Sentinel_Failure struct {
	// contains filtered or unexported fields
}

Discovery errors

type DiscoveryError_Slave_FailoverInProgress

type DiscoveryError_Slave_FailoverInProgress struct {
	// contains filtered or unexported fields
}

type DiscoveryError_Slave_SingleServerFailure

type DiscoveryError_Slave_SingleServerFailure struct {
	// contains filtered or unexported fields
}

type DiscoveryError_UnknownRole_SingleServerFailure

type DiscoveryError_UnknownRole_SingleServerFailure struct {
	// contains filtered or unexported fields
}

type DiscoveryOption

type DiscoveryOption int
const (
	SlaveReadOnlyDiscoveryOpt DiscoveryOption = iota
	SaveConfigDiscoveryOpt
	OnlyMasterDiscoveryOpt
	SlavePriorityDiscoveryOpt
	ReplicationInfoDiscoveryOpt
)

type DiscoveryOptionSet

type DiscoveryOptionSet []DiscoveryOption

func (DiscoveryOptionSet) Has

type RedisServer

type RedisServer struct {
	*redis.Server
	Role   client.Role
	Config map[string]string
	Info   map[string]string
}

func NewRedisServerFromParams

func NewRedisServerFromParams(srv *redis.Server, role client.Role, config map[string]string) *RedisServer

func NewRedisServerFromPool

func NewRedisServerFromPool(connectionString string, alias *string, pool *redis.ServerPool) (*RedisServer, error)

func (*RedisServer) Discover

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

Discover returns the characteristincs for a given redis Server It always gets the role first

func (*RedisServer) InitMaster

func (srv *RedisServer) InitMaster(ctx context.Context) (bool, error)

func (*RedisServer) InitSlave

func (srv *RedisServer) InitSlave(ctx context.Context, master *RedisServer) (bool, error)

type SentinelServer

type SentinelServer struct {
	*redis.Server
}

SentinelServer represents a sentinel Pod

func NewHighAvailableSentinel

func NewHighAvailableSentinel(servers map[string]string, pool *redis.ServerPool) ([]*SentinelServer, error)

func NewSentinelServerFromParams

func NewSentinelServerFromParams(srv *redis.Server) *SentinelServer

func NewSentinelServerFromPool

func NewSentinelServerFromPool(connectionString string, alias *string, pool *redis.ServerPool) (*SentinelServer, error)

func (*SentinelServer) IsMonitoringShards

func (sentinel *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 (sentinel *SentinelServer) Monitor(ctx context.Context, cluster *Cluster, quorum int) ([]string, error)

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

type Shard

type Shard struct {
	Name    string
	Servers []*RedisServer
	// contains filtered or unexported fields
}

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

func NewShardFromServers

func NewShardFromServers(name string, pool *redis.ServerPool, servers ...*RedisServer) *Shard

func NewShardFromTopology

func NewShardFromTopology(name string, servers map[string]string, pool *redis.ServerPool) (*Shard, error)

NewShardFromTopology returns a Shard object given the passed redis server URLs

func (*Shard) Discover

func (shard *Shard) Discover(ctx context.Context, sentinel *SentinelServer, options ...DiscoveryOption) error

Discover retrieves the options for all the servers in the shard If a SentinelServer is provided, it will be used to autodiscover servers and roles in the shard

func (*Shard) GetMaster

func (shard *Shard) GetMaster() (*RedisServer, error)

GetMaster returns the host:port of the master server in a shard or error if zero or more than one master is found

func (*Shard) GetServerByID

func (shard *Shard) GetServerByID(hostport string) (*RedisServer, error)

func (*Shard) GetSlavesRO

func (shard *Shard) GetSlavesRO() []*RedisServer

func (*Shard) GetSlavesRW

func (shard *Shard) GetSlavesRW() []*RedisServer

func (*Shard) Init

func (shard *Shard) Init(ctx context.Context, masterHostPort string) ([]string, error)

Init initializes the shard if not already initialized

type ShardDiscoveryError

type ShardDiscoveryError struct {
	ShardName string
	Errors    operatorutils.MultiError
}

func (ShardDiscoveryError) Error

func (e ShardDiscoveryError) Error() string

func (ShardDiscoveryError) Unwrap

func (e ShardDiscoveryError) Unwrap() []error

Jump to

Keyboard shortcuts

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