leaderelection

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StateFollower defines currentState of backup-restore as "Follower".
	StateFollower = "Follower"
	// StateCandidate defines currentState of backup-restore as "Candidate".
	StateCandidate = "Candidate"
	// StateLeader defines currentState of backup-restore as "Leader".
	StateLeader = "Leader"
	// StateUnknown defines currentState of backup-restore as "UnknownState".
	StateUnknown = "UnknownState"

	// DefaultCurrentState defines default currentState of backup-restore as "Follower".
	DefaultCurrentState = StateFollower

	// NoLeaderState defines the state when etcd returns LeaderID as 0.
	NoLeaderState uint64 = 0
)

Variables

This section is empty.

Functions

func EtcdMemberStatus

func EtcdMemberStatus(ctx context.Context, etcdConnectionConfig *brtypes.EtcdConnectionConfig, etcdConnectionTimeout time.Duration, logger *logrus.Entry) (bool, bool, error)

EtcdMemberStatus checks whether the current instance of backup-restore is leader or not. It also returns the boolean indicating the presence of learner(non-voting) member.

Types

type LeaderElector

type LeaderElector struct {
	// CurrentState defines currentState of backup-restore for LeaderElection.
	CurrentState         string
	Config               *brtypes.Config
	EtcdConnectionConfig *brtypes.EtcdConnectionConfig

	Callbacks         *brtypes.LeaderCallbacks
	LeaseCallbacks    *brtypes.MemberLeaseCallbacks
	PromoteCallback   *brtypes.PromoteLearnerCallback
	CheckMemberStatus brtypes.EtcdMemberStatusCallbackFunc
	// contains filtered or unexported fields
}

LeaderElector holds the all configuration necessary to elect backup-restore Leader.

func NewLeaderElector

func NewLeaderElector(logger *logrus.Entry, etcdConnectionConfig *brtypes.EtcdConnectionConfig, leaderElectionConfig *brtypes.Config, callbacks *brtypes.LeaderCallbacks, memberLeaseCallbacks *brtypes.MemberLeaseCallbacks, memberStatusFunc brtypes.EtcdMemberStatusCallbackFunc, promoteCallback *brtypes.PromoteLearnerCallback) (*LeaderElector, error)

NewLeaderElector returns LeaderElector configurations.

func (*LeaderElector) Run

func (le *LeaderElector) Run(ctx context.Context) error

Run starts the LeaderElection loop to elect the backup-restore's Leader and keep checking the leadership status of backup-restore.

Jump to

Keyboard shortcuts

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