leader

package
v0.0.0-...-83a686f Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CHECKER state = iota
	PRETENDER
	USURPER
	LEADER
	STOPPED
)

Variables

View Source
var (
	IndexName = common.IndexName(".tasques_leader_locks")
)

Functions

func NewLeaderLock

func NewLeaderLock(leaderLockDocId common.DocumentID, client *elasticsearch.Client, loopInterval time.Duration, leaderReportLagTolerance time.Duration, tracer tracing.Tracer) leader.Lock

NewLeaderLock returns a new leader.Lock

Generates a random process id for the returned instance.

Types

type Conflict

type Conflict struct{}

func (Conflict) Error

func (n Conflict) Error() string

type EsLock

type EsLock struct {
	// contains filtered or unexported fields
}

* EsLock implements a very basic state machine for checking if the current `EsLock` process * is the leader based on what is stored inside the document in the leader index, as identified * by ID. * * It does this by using a simple polling mechanism along with a looping FSM that makes use of * The concurrent locking mechanisms in ES to figure out it should attempt to become the leader. * * Limitations: * - Not real time (polling..) * - Depends on not having too much drift in machine clock between all servers (time diff).

func (*EsLock) IsLeader

func (e *EsLock) IsLeader() bool

func (*EsLock) SetUTCGetter

func (e *EsLock) SetUTCGetter(getter func() time.Time)

Ignore: this is for tests

func (*EsLock) Start

func (e *EsLock) Start()

func (*EsLock) Stop

func (e *EsLock) Stop()

type NotFound

type NotFound struct{}

func (NotFound) Error

func (n NotFound) Error() string

Jump to

Keyboard shortcuts

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