candidate

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: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConnectedEvent = iota
	DisconnectedEvent
	LeaderUpgradeEvent
	DowngradeEvent
)
View Source
const EventsChanSize = 10
View Source
const (
	LeaderChanSize = 6
)

Variables

View Source
var (
	AlreadyRegisteredError  = errors.New("already registered")
	NotRegisteredError      = errors.New("not registered")
	NotEnrolledError        = errors.New("candidate is not presently enrolled in the election")
	InvalidChildrenLenError = errors.New("0 children listed afer created protected ephemeral sequential - this should never happen")

	DefaultConnCheckFrequency = 5 * time.Second // Default frequency of connection checks.
)

Functions

This section is empty.

Types

type Candidate

type Candidate struct {
	ElectionPath       string
	Node               *Node
	ConnCheckFrequency time.Duration // Frequency of connection checks.

	Debug bool
	// contains filtered or unexported fields
}

func New

func New(electionPath string, node *Node) *Candidate

func (*Candidate) Participants

func (c *Candidate) Participants(conn *zk.Conn) (participants []Node, err error)

func (*Candidate) Register

func (c *Candidate) Register(conn *zk.Conn) (<-chan *Node, error)

func (*Candidate) Registered

func (c *Candidate) Registered() bool

func (*Candidate) Unregister

func (c *Candidate) Unregister() error

type Event

type Event int

type Node

type Node struct {
	Uuid string
	Host string
	Port int
	Data interface{}
}

func NewNode

func NewNode(uid string, host string, port int, data interface{}) *Node

type Participant

type Participant struct {
	Config     ParticipantConfig
	EventsChan <-chan Event
	StopChan   chan<- struct{}
}

func Participate

func Participate(config ParticipantConfig) (participant Participant)

type ParticipantConfig

type ParticipantConfig struct {
	ElectionPath string
	ZkAddrs      []string
	ZkTimeout    time.Duration
	Node         *Node
	Debug        bool
}

type ZNodes

type ZNodes []string

func (ZNodes) Len

func (zNodes ZNodes) Len() int

func (ZNodes) Less

func (zNodes ZNodes) Less(i, j int) bool

func (ZNodes) Swap

func (zNodes ZNodes) Swap(i, j int)

Jump to

Keyboard shortcuts

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