elector

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: Apache-2.0 Imports: 6 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 struct {
	// contains filtered or unexported fields
}

Elector is a helper type for performing and managing leader election

func New

func New(ctx context.Context, client *api.Client) (*Elector, error)

New returns a fully initialized Elector that can be used to obtain leader election

func (*Elector) IsLeader

func (e *Elector) IsLeader() bool

IsLeader returns true if this node is currently the leader

func (*Elector) SeizeThrone

func (e *Elector) SeizeThrone() <-chan struct{}

SeizeThrone attempts to attain a leader lock among multiple instances. The returned channel return a value if this instance was elected

func (*Elector) StepDown

func (e *Elector) StepDown()

StepDown gracefully steps down as the leader (retiring to the country side to till the earth like a virtuous Roman citizen). This should generally be called with `defer` once the Elector is created so that it can step down

Jump to

Keyboard shortcuts

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