Documentation ¶
Index ¶
- Constants
- Variables
- type AfterFailoverHandler
- type App
- type BeforeFailoverHandler
- type Cluster
- type Config
- type Group
- type Node
- type Raft
- func (r *Raft) AddMasters(addrs []string, timeout time.Duration) error
- func (r *Raft) AddPeer(peerAddr string) error
- func (r *Raft) Barrier(timeout time.Duration) error
- func (r *Raft) Close()
- func (r *Raft) DelMasters(addrs []string, timeout time.Duration) error
- func (r *Raft) DelPeer(peerAddr string) error
- func (r *Raft) GetPeers() ([]string, error)
- func (r *Raft) IsLeader() bool
- func (r *Raft) Leader() string
- func (r *Raft) LeaderCh() <-chan bool
- func (r *Raft) SetMasters(addrs []string, timeout time.Duration) error
- func (r *Raft) SetPeers(peerAddrs []string) error
- type RaftConfig
- type Zk
- func (z *Zk) AddMasters(addrs []string, timeout time.Duration) error
- func (z *Zk) Barrier(timeout time.Duration) error
- func (z *Zk) Close()
- func (z *Zk) DelMasters(addrs []string, timeout time.Duration) error
- func (z *Zk) IsLeader() bool
- func (z *Zk) LeaderCh() <-chan bool
- func (z *Zk) SetMasters(addrs []string, timeout time.Duration) error
- type ZkConfig
Constants ¶
View Source
const ( ClusterStateNew = "new" ClusterStateExisting = "existing" )
View Source
const ( MastersStateNew = "new" MastersStateExisting = "existing" )
View Source
const ( MasterType = "master" SlaveType = "slave" )
View Source
const ( ConnectState = "connect" ConnectingState = "connecting" ConnectedState = "connected" SyncState = "sync" )
Variables ¶
View Source
var ( ErrNodeDown = errors.New("Node is down") ErrNodeAlive = errors.New("Node may be still alive") ErrNoCandidate = errors.New("no proper candidate to be promoted to master") ErrNodeType = errors.New("Node is not the expected type") )
View Source
var ( // If failover handler return this error, we will give up future handling. ErrGiveupFailover = errors.New("Give up failover handling") )
Functions ¶
This section is empty.
Types ¶
type AfterFailoverHandler ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
func (*App) AddAfterFailoverHandler ¶
func (a *App) AddAfterFailoverHandler(f AfterFailoverHandler)
func (*App) AddBeforeFailoverHandler ¶
func (a *App) AddBeforeFailoverHandler(f BeforeFailoverHandler)
type BeforeFailoverHandler ¶
type Config ¶
type Config struct { Addr string `toml:"addr"` Masters []string `toml:"masters"` MastersState string `toml:"masters_state"` CheckInterval int `toml:"check_interval"` MaxDownTime int `toml:"max_down_time"` Broker string `toml:"broker"` Raft RaftConfig `toml:"raft"` Zk ZkConfig `toml:"zk"` }
func NewConfigWithFile ¶
type Group ¶
type Group struct { Master *Node Slaves map[string]*Node CheckErrNum sync2.AtomicInt32 // contains filtered or unexported fields }
A group contains a Redis master and one or more slaves It will use role command per second to check master's alive and find slaves automatically.
type Node ¶
type Node struct { // Redis address, only support tcp now Addr string // Replication offset Offset int64 // contains filtered or unexported fields }
A node represents a real redis server
type Raft ¶
type Raft struct {
// contains filtered or unexported fields
}
redis-failover uses raft to elect the cluster leader and do monitoring and failover.
type RaftConfig ¶
Click to show internal directories.
Click to hide internal directories.