election

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2021 License: MIT Imports: 11 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 struct {
	RoleCh chan role.Role
	// contains filtered or unexported fields
}

Election for leader node election

func New

func New(opts ...Option) (e *Election, err error)

New returns a new Election

func (*Election) Leader

func (e *Election) Leader() (name string, err error)

Leader returns name of current leader node

func (*Election) Resign

func (e *Election) Resign(ctx context.Context) (err error)

Resign resign election

func (*Election) Role

func (e *Election) Role() role.Role

Role returns role current node

func (*Election) Run

func (e *Election) Run(ctx context.Context)

Run start election process

func (*Election) SetRole

func (e *Election) SetRole(r role.Role)

SetRole sets node current role

type Option

type Option func(e *Election)

Option is function of set election

func OptionNode

func OptionNode(node *node.Node) Option

OptionNode sets election node

func OptionPrefix

func OptionPrefix(prefix string) Option

OptionPrefix sets election prefix

func OptionTTL

func OptionTTL(ttl int) Option

OptionTTL sets election ttl

Jump to

Keyboard shortcuts

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