elect

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Election

type Election interface {
	// Initialize initializes election, such as master change watch
	Initialize()
	// Elect elects master, include retry elect when elect fail
	Elect()
	// Close closes master elect
	Close()
	// IsMaster returns current node if is master
	IsMaster() bool
	// GetMaster returns the current master info
	GetMaster() *models.Master
}

Election represents master elect

func NewElection

func NewElection(ctx context.Context, repo state.Repository, node models.Node, ttl int64, listener Listener) Election

NewElection returns a new election

type Listener

type Listener interface {
	// OnFailOver triggers master fail-over, current node become master,
	// if fail over is failure return err
	OnFailOver() error
	// OnResignation triggers master resignation.
	OnResignation()
}

Listener represent master change callback interface.

Jump to

Keyboard shortcuts

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