redis

package
v0.0.0-...-2ca7562 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

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

Node represents API to query/manipulate a single Redis node

func NewNode

func NewNode(config *config.Config, logger *slog.Logger, fqdn string) (*Node, error)

NewNode is a Node constructor

func (*Node) Close

func (n *Node) Close() error

Close closes underlying Redis connection

func (*Node) ClusterGetID

func (n *Node) ClusterGetID(ctx context.Context) (string, error)

ClusterGetID returns cluster node id of node

func (*Node) ClusterMakeReplica

func (n *Node) ClusterMakeReplica(ctx context.Context, targetID string) error

ClusterMakeReplica makes node replica of target in cluster mode

func (*Node) ClusterMeet

func (n *Node) ClusterMeet(ctx context.Context, addr string, port, clusterBusPort int) error

ClusterMeet makes replica join the cluster

func (*Node) ClusterPromoteForce

func (n *Node) ClusterPromoteForce(ctx context.Context) error

ClusterPromoteForce makes node primary in cluster mode if master/majority of masters is reachable

func (*Node) ClusterPromoteTakeover

func (n *Node) ClusterPromoteTakeover(ctx context.Context) error

ClusterPromoteTakeover makes node primary in cluster mode if majority of masters is not reachable

func (*Node) DisconnectClients

func (n *Node) DisconnectClients(ctx context.Context, ctype string) error

DisconnectClients disconnects all connected clients with specified type

func (*Node) EmptyQuorumReplicas

func (n *Node) EmptyQuorumReplicas(ctx context.Context) error

EmptyQuorumReplicas sets quorum replicas to empty value (as it should be on replicas)

func (*Node) EvaluatePing

func (n *Node) EvaluatePing() (bool, bool)

func (*Node) FQDN

func (n *Node) FQDN() string

FQDN returns Node fqdn

func (*Node) GetIP

func (n *Node) GetIP() (string, error)

GetIP returns first ip as string

func (*Node) GetIPs

func (n *Node) GetIPs() []string

GetIPs returns a string slice of node ips

func (*Node) GetInfo

func (n *Node) GetInfo(ctx context.Context) (map[string]string, error)

GetInfo returns raw info map

func (*Node) GetMinReplicas

func (n *Node) GetMinReplicas(ctx context.Context) (int, error)

GetMinReplicas returns number of connected replicas to accept writes on node

func (*Node) GetQuorumReplicas

func (n *Node) GetQuorumReplicas(ctx context.Context) (string, error)

GetQuorumReplicas returns a set of quorum replicas

func (*Node) HasClusterSlots

func (n *Node) HasClusterSlots(ctx context.Context) (bool, error)

HasClusterSlots checks if node has any slot assigned

func (*Node) IsClusterMajorityAlive

func (n *Node) IsClusterMajorityAlive(ctx context.Context) (bool, error)

IsClusterMajorityAlive checks if majority of masters in cluster are not failed

func (*Node) IsClusterNodeAlone

func (n *Node) IsClusterNodeAlone(ctx context.Context) (bool, error)

IsClusterNodeAlone checks if node sees only itself

func (*Node) IsLocal

func (n *Node) IsLocal() bool

IsLocal returns true if Node running on the same host as calling rdsync process

func (*Node) IsOffline

func (n *Node) IsOffline(ctx context.Context) (bool, error)

IsOffline returns Offline status for node

func (*Node) IsReadOnly

func (n *Node) IsReadOnly(ctx context.Context) (bool, error)

IsReadOnly returns ReadOnly status for node

func (*Node) IsReplPaused

func (n *Node) IsReplPaused(ctx context.Context) (bool, error)

IsReplPaused returns pause status of replication on node

func (*Node) MatchHost

func (n *Node) MatchHost(host string) bool

MatchHost checks if node has target hostname or ip

func (*Node) PauseReplication

func (n *Node) PauseReplication(ctx context.Context) error

PauseReplication pauses replication from master on node

func (*Node) RefreshAddrs

func (n *Node) RefreshAddrs() error

RefreshAddrs updates internal ip address list if ttl exceeded

func (*Node) Restart

func (n *Node) Restart(ctx context.Context) error

Restart restarts redis server

func (*Node) ResumeReplication

func (n *Node) ResumeReplication(ctx context.Context) error

ResumeReplication starts replication from master on node

func (*Node) SentinelMakeReplica

func (n *Node) SentinelMakeReplica(ctx context.Context, target string) error

SentinelMakeReplica makes node replica of target in sentinel mode

func (*Node) SentinelPromote

func (n *Node) SentinelPromote(ctx context.Context) error

SentinelPromote makes node primary in sentinel mode

func (*Node) SetMinReplicas

func (n *Node) SetMinReplicas(ctx context.Context, value int) (error, error)

SetMinReplicas sets desired number of connected replicas to accept writes on node

func (*Node) SetOffline

func (n *Node) SetOffline(ctx context.Context) error

SetOffline disallows non-localhost connections and drops all existing clients (except rdsync ones)

func (*Node) SetOnline

func (n *Node) SetOnline(ctx context.Context) error

SetOnline allows non-localhost connections

func (*Node) SetQuorumReplicas

func (n *Node) SetQuorumReplicas(ctx context.Context, value string) (error, error)

SetQuorumReplicas sets desired quorum replicas

func (*Node) SetReadOnly

func (n *Node) SetReadOnly(ctx context.Context, disconnect bool) (error, error)

SetReadOnly makes node read-only by setting min replicas to unreasonably high value and disconnecting clients

func (*Node) String

func (n *Node) String() string

type NodeConfiguration

type NodeConfiguration struct {
	// Priority - is a host priority to become master. Can be changed via CLI.
	Priority int `json:"priority"`
}

NodeConfiguration is a dcs node configuration for redis replica

func DefaultNodeConfiguration

func DefaultNodeConfiguration() *NodeConfiguration

DefaultNodeConfiguration returns default node configuration (matches upstream sentinel settings)

type SentiCacheMaster

type SentiCacheMaster struct {
	Name          string
	IP            string
	Port          int
	RunID         string
	Quorum        int
	ParallelSyncs int
	ConfigEpoch   uint64
}

SentiCacheMaster represents the redis master as seen by senticache

type SentiCacheNode

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

SentiCacheNode represents API to query/manipulate a single Redis SentiCache node

func NewSentiCacheNode

func NewSentiCacheNode(config *config.Config, logger *slog.Logger) (*SentiCacheNode, error)

NewSentiCacheNode is a SentiCacheNode constructor

func (*SentiCacheNode) Close

func (s *SentiCacheNode) Close() error

Close closes underlying Redis connection

func (*SentiCacheNode) Update

func (s *SentiCacheNode) Update(ctx context.Context, state *SentiCacheState) error

Update sets in-memory state of senticache

type SentiCacheReplica

type SentiCacheReplica struct {
	IP                    string
	Port                  int
	RunID                 string
	MasterLinkDownTime    int64
	SlavePriority         int
	ReplicaAnnounced      int
	MasterHost            string
	MasterPort            int
	SlaveMasterLinkStatus int
	SlaveReplOffset       int64
}

SentiCacheReplica represents the redis replica as seen by senticache

type SentiCacheSentinel

type SentiCacheSentinel struct {
	Name  string
	RunID string
	IP    string
	Port  int
}

SentiCacheSentinel represents the "other" senticache in senticache

type SentiCacheState

type SentiCacheState struct {
	Master    SentiCacheMaster
	Replicas  []SentiCacheReplica
	Sentinels []SentiCacheSentinel
}

SentiCacheState represents the desired senticache state

type Shard

type Shard struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Shard contains a set of Redis nodes

func NewShard

func NewShard(config *config.Config, logger *slog.Logger, dcs dcs.DCS) *Shard

NewShard is a Shard constrcutor

func (*Shard) Close

func (s *Shard) Close()

Close closes all established connections to nodes

func (*Shard) Get

func (s *Shard) Get(host string) *Node

Get returns Redis Node by host name

func (*Shard) GetNodeConfiguration

func (s *Shard) GetNodeConfiguration(host string) (*NodeConfiguration, error)

GetNodeConfiguration returns current node configuration from dcs

func (*Shard) GetShardHostsFromDcs

func (s *Shard) GetShardHostsFromDcs() ([]string, error)

GetShardHostsFromDcs returns current shard hosts from dcs state

func (*Shard) Hosts

func (s *Shard) Hosts() []string

Hosts returns all nodes from local state

func (*Shard) Local

func (s *Shard) Local() *Node

Local returns Redis Node running on the same not as current rdsync process

func (*Shard) UpdateHostsInfo

func (s *Shard) UpdateHostsInfo() error

UpdateHostsInfo reads host names from DCS and updates shard state

Jump to

Keyboard shortcuts

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