election

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: MIT Imports: 6 Imported by: 0

README

election

A Go library to manage a cluster using Zookeeper.

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       `json:"zkURL"`
	ZKElectionNodeURI      string         `json:"zkElectionNodeURI"`
	ZKSlaveNodesURI        string         `json:"zkSlaveNodesURI"`
	ReconnectionTimeout    funks.Duration `json:"reconnectionTimeout"`
	SessionTimeout         funks.Duration `json:"sessionTimeout"`
	ClusterChangeCheckTime funks.Duration `json:"clusterChangeCheckTime"`
	ClusterChangeWaitTime  funks.Duration `json:"clusterChangeWaitTime"`
}

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) (*Manager, error)

New - creates a new instance

func (*Manager) Disconnect

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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