election

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2018 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const Disconnected = 3

Disconnected - int signal for the message channel

View Source
const Master = 1

Master - int signal for the election channel

View Source
const Slave = 2

Slave - int signal for the election channel

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 int
	SessionTimeout      int
}

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) GetClusterInfo

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

GetClusterInfo - return cluster info

func (*Manager) GetHostname

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

GetHostname - retrieves this node hostname from the OS

func (*Manager) IsMaster

func (e *Manager) IsMaster() bool

IsMaster - check if the cluster is the master

func (*Manager) Start

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

Start - starts to listen zk events

func (*Manager) Terminate

func (e *Manager) Terminate()

Terminate - end all channels and disconnects from the zookeeper

Jump to

Keyboard shortcuts

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