election

package
v0.0.0-...-a7a8f6c Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Elector

type Elector interface {
	// Stop stop elector
	Stop(frag uint64)

	// CurrentLeader returns current leader
	CurrentLeader(frag uint64) (uint64, error)

	// ElectionLoop run leader election loop
	ElectionLoop(ctx context.Context, frag, currentPeerID uint64, nodeChecker func(uint64) bool, becomeLeader, becomeFollower func())

	// ChangeLeaderTo change leader to
	ChangeLeaderTo(frag uint64, oldLeader, newLeader uint64) error
}

Elector leader election

func NewElector

func NewElector(opts ...Option) (Elector, error)

NewElector create a elector by options

type Option

type Option func(*options)

Option option for election

func WithEtcd

func WithEtcd(value *clientv3.Client) Option

WithEtcd set etcd client

func WithLeaderLeaseSec

func WithLeaderLeaseSec(value int64) Option

WithLeaderLeaseSec set leader lease time in seconds

func WithLeaderPath

func WithLeaderPath(value string) Option

WithLeaderPath set leader path

func WithLockPath

func WithLockPath(value string) Option

WithLockPath set lock path

Jump to

Keyboard shortcuts

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