Documentation ¶
Index ¶
- type Coordinator
- func (cc *Coordinator) Id() (id string)
- func (cc *Coordinator) Leader() *primitives.Node
- func (cc *Coordinator) LeaderData() string
- func (cc *Coordinator) Members() (nodes []primitives.Node, err error)
- func (cc *Coordinator) Mode() string
- func (cc *Coordinator) Start() error
- func (cc *Coordinator) Stop() error
- func (cc *Coordinator) Subscribe(subChan chan primitives.Update)
- func (cc *Coordinator) Unsubscribe(unsubChan chan primitives.Update)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Coordinator ¶
type Coordinator struct { LocalNode primitives.Node // contains filtered or unexported fields }
func NewCoordinator ¶
func NewCoordinator(zkServers []string, sessionTimeout time.Duration, leaderElectionPath string, data string, subscribers ...chan primitives.Update) (*Coordinator, error)
NewCoordinator creates a new cluster client.
leaderElectionPath is the ZooKeeper path to conduct elections under.
func (*Coordinator) Id ¶
func (cc *Coordinator) Id() (id string)
func (*Coordinator) Leader ¶
func (cc *Coordinator) Leader() *primitives.Node
Leader returns the Node representation of the current leader, or nil if there isn't one right now. string if the current leader is unknown.
func (*Coordinator) LeaderData ¶
func (cc *Coordinator) LeaderData() string
func (*Coordinator) Members ¶
func (cc *Coordinator) Members() (nodes []primitives.Node, err error)
func (*Coordinator) Mode ¶
func (cc *Coordinator) Mode() string
Mode returns one of:
"follower" - indicates that this node is not currently the leader.
"leader" - indicates that this node IS the current leader.
func (*Coordinator) Start ¶
func (cc *Coordinator) Start() error
func (*Coordinator) Stop ¶
func (cc *Coordinator) Stop() error
func (*Coordinator) Subscribe ¶
func (cc *Coordinator) Subscribe(subChan chan primitives.Update)
Subscribe adds a channel to the slice of subscribers who get notified when the leader changes.
func (*Coordinator) Unsubscribe ¶
func (cc *Coordinator) Unsubscribe(unsubChan chan primitives.Update)
Unsubscribe removes a channel frmo the slice of subscribers.
Click to show internal directories.
Click to hide internal directories.