leader

package module
v0.0.0-...-6ede3d2 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2019 License: MIT Imports: 3 Imported by: 0

README

leader

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HeartBeat               = 15 * time.Second
	Timeout                 = 25 * time.Second
	Op            Operation = noop{}
	OnLeadChanged           = func(lead bool) {}
)

Configs

Functions

func Acquire

func Acquire()

Acquire starts acquire loop (must run in go routine)

func Lead

func Lead() bool

Lead returns true if current process is the leader

func ProcessID

func ProcessID() string

ProcessID returns process id

func Run

func Run(f func()) bool

Run runs f if current process is the leader

Types

type Operation

type Operation interface {
	Begin() error
	Commit() error
	Rollback() error

	Current() (processID string, lastHeartBeat, now time.Time, err error)
	TryAcquire(processID string) error
}

Operation type

Jump to

Keyboard shortcuts

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