election

package
v1.18.1 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2019 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const ClusterChanged = 3

ClusterChanged - signals for cluster change

View Source
const Disconnected = 4

Disconnected - int signal for disconnection

View Source
const (
	// EventDisconnected - specifies a custom event for disconnection
	EventDisconnected zk.EventType = 99
)
View Source
const Master = 1

Master - signals for master role acquisition

View Source
const Slave = 2

Slave - signals for slave role acquisition

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	IsMaster bool
	Master   string
	Slaves   []string
	Nodes    []string
	NumNodes int
}

Cluster - has cluster info

type Config

type Config struct {
	ZKURL                  []string
	ZKElectionNodeURI      string
	ZKSlaveNodesURI        string
	ReconnectionTimeout    string
	SessionTimeout         string
	ClusterChangeCheckTime string
	ClusterChangeWaitTime  string
}

Config - configures the election

type Manager

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

Manager - handles the zookeeper election

func New

func New(config *Config, logger *zap.Logger) (*Manager, error)

New - creates a new instance

func (*Manager) Disconnect added in v1.18.0

func (m *Manager) Disconnect()

Disconnect - disconnects from the zookeeper

func (*Manager) GetClusterInfo

func (m *Manager) GetClusterInfo() (*Cluster, error)

GetClusterInfo - return cluster info

func (*Manager) GetHostname

func (m *Manager) GetHostname() (string, error)

GetHostname - retrieves this node hostname from the OS

func (*Manager) IsMaster

func (m *Manager) IsMaster() bool

IsMaster - check if the cluster is the master

func (*Manager) Start

func (m *Manager) Start() (*chan int, error)

Start - starts to listen zk events

Jump to

Keyboard shortcuts

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