cluster

package
v0.0.0-...-64299d5 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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