leadership

package
v0.0.51 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AvailabilityCriteria

type AvailabilityCriteria func() bool

type Candidate

type Candidate interface {
	Init(context.Context)
	Deinit(context.Context)
	AddAvailabilityCriteria(AvailabilityCriteria)
	TryBecomeLeader(context.Context) bool
	RenewLeadershipLease(context.Context)
	IsAvailable() bool
	IsCurrentLeader(context.Context) bool
	UpdateCandidateStatus(context.Context, bool)
	TrimCandidates(context.Context)
	GetLeaderCandidates(context.Context) []string
	SetState(context.Context, State)
	SetLeaderAndCandidateFields(context.Context)
	DoWork(context.Context)

	LosingLeadership() signalslots.Signal
	BecameLeader() signalslots.Signal
	BecameFollower() signalslots.Signal
	BecameUnavailable() signalslots.Signal

	IsCurrentLeaderCheck() <-chan time.Time
	CandidateUpdate() <-chan time.Time
	LeaderAttempt() <-chan time.Time
	LeaseRenewal() <-chan time.Time
}

type State

type State interface {
	DoWork(context.Context, Candidate)
	OnEnterState(context.Context, Candidate, State)
	Name() string
}

type Store added in v0.0.50

type Store interface {
	Connect(context.Context)
	Disconnect(context.Context)
	IsConnected(context.Context) bool

	TempSet(ctx context.Context, key string, value string, expiration time.Duration) bool
	TempGet(ctx context.Context, key string) string
	TempExpire(ctx context.Context, key string, expiration time.Duration)
	TempDel(ctx context.Context, key string)

	SortedSetAdd(ctx context.Context, key string, member string, score float64) int64
	SortedSetRemove(ctx context.Context, key string, member string) int64
	SortedSetRemoveRangeByRank(ctx context.Context, key string, start, stop int64) int64
	SortedSetRangeByScoreWithScores(ctx context.Context, key string, min, max string) []store.SortedSetMember
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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