Documentation ¶
Index ¶
- type Cluster
- func (cluster *Cluster) Discover(ctx context.Context, options ...DiscoveryOption) error
- func (cluster *Cluster) GetSentinel(pctx context.Context) *SentinelServer
- func (cluster *Cluster) GetShardNames() []string
- func (cluster Cluster) LookupServerByID(hostport string) *RedisServer
- func (cluster Cluster) LookupShardByName(name string) *Shard
- func (cluster *Cluster) SentinelDiscover(ctx context.Context, opts ...DiscoveryOption) error
- type DiscoveryError_Master_SingleServerFailure
- type DiscoveryError_Sentinel_Failure
- type DiscoveryError_Slave_FailoverInProgress
- type DiscoveryError_Slave_SingleServerFailure
- type DiscoveryError_UnknownRole_SingleServerFailure
- type DiscoveryOption
- type DiscoveryOptionSet
- type RedisServer
- type SentinelServer
- type Shard
- func (shard *Shard) Discover(ctx context.Context, sentinel *SentinelServer, options ...DiscoveryOption) error
- func (shard *Shard) GetMaster() (*RedisServer, error)
- func (shard *Shard) GetServerByID(hostport string) (*RedisServer, error)
- func (shard *Shard) GetSlavesRO() []*RedisServer
- func (shard *Shard) GetSlavesRW() []*RedisServer
- func (shard *Shard) Init(ctx context.Context, masterHostPort string) ([]string, error)
- type ShardDiscoveryError
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 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) LookupServerByID ¶
func (cluster Cluster) LookupServerByID(hostport string) *RedisServer
func (Cluster) LookupShardByName ¶
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 ¶
func (set DiscoveryOptionSet) Has(opt DiscoveryOption) bool
type RedisServer ¶
type RedisServer struct { *redis.Server Role client.Role Config map[string]string Info map[string]string }
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 ¶
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
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
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