leaderelection

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultConfig = &Config{
		LeaseNamespace: "furiko-system",
		LeaseDuration:  30 * time.Second,
		RenewDeadline:  15 * time.Second,
		RetryPeriod:    5 * time.Second,
	}
)

Functions

func GenerateLeaseIdentity

func GenerateLeaseIdentity() (string, error)

GenerateLeaseIdentity generates a unique lease identity that can be used in a leader election.

func ObserveLeaderElected

func ObserveLeaderElected(leaseName, leaseID string, isLeader bool)

Types

type Config

type Config struct {
	LeaseName      string
	LeaseNamespace string
	LeaseDuration  time.Duration
	RenewDeadline  time.Duration
	RetryPeriod    time.Duration
}

func (*Config) PrepareValues

func (c *Config) PrepareValues() *Config

type Coordinator

type Coordinator interface {
	IsLeader() bool
	GetLeader() string
	Wait(ctx context.Context) error
	GiveUp()
	GetLeaseName() string
	GetLeaseID() string
}

func NewCoordinator

func NewCoordinator(client coordinationv1.LeasesGetter, config *Config) (Coordinator, error)

NewCoordinator creates a new Coordinator with a randomly generated identity.

func NewCoordinatorWithIdentity

func NewCoordinatorWithIdentity(client coordinationv1.LeasesGetter, id string, config *Config) (Coordinator, error)

NewCoordinatorWithIdentity creates a new Coordinator with the given identity.

Jump to

Keyboard shortcuts

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