election

package
v0.0.0-...-cd31975 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package election implements master elections. Currently only etcd is supported.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Election

type Election interface {
	// Run enters into the election using id as the identifier.
	Run(ctx context.Context, id string) error
	// IsMaster returns a channel on which the status of the
	// election will be broadcasted (true means that this is the
	// master).
	IsMaster() chan bool
	// Current returns a channel on which the name of the current
	// master is broadcasted. The empty string means that the
	// master is currently unknown.
	Current() chan string
}

Election represents a master election.

func Etcd

func Etcd(endpoints []string, lock string, delay time.Duration) Election

Etcd returns an etcd based master election (endpoints are used to connect to the etcd cluster). The participants synchronize on lock, and the master has delay time to renew its lease. Higher values of delay may lead to more stable mastership at the cost of potentially longer periods without any master.

func Trivial

func Trivial() Election

Trivial returns a trivial election: the participant immediately wins. Use this if you need the election interface, but don't really care about the master election (eg. you'll never have more than one candidate).

Jump to

Keyboard shortcuts

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