Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateLeaderIdentity ¶
func GenerateLeaderIdentity() string
GenerateLeaderIdentity generates a string used for leader identity in the leader election process, this identity will be mostly the hostname, or if for some reason that cannot be fetched a random string.
func RunElection ¶
func RunElection( ctx context.Context, leaderElectionIdentity string, lock *ClabernetesLeaseLock, timers Timers, startLeading func(c context.Context), stopLeading func(), newLeader func(newLeaderIdentity string), )
RunElection runs the leader election process executing the provided callbacks for OnStartedLeading and OnStoppedLeading when those events happen.
Types ¶
type ClabernetesLeaseLock ¶
type ClabernetesLeaseLock struct { *resourcelock.LeaseLock // contains filtered or unexported fields }
ClabernetesLeaseLock wraps resourcelock.LeaseLock Create method and adds labels to the created lease.
func GetLeaseLock ¶
func GetLeaseLock( client *kubernetes.Clientset, appName, namespace, lockName, leaderIdentity string, ) *ClabernetesLeaseLock
GetLeaseLock returns a LeaseLock object for the given namespace/lock name/identity.
func (*ClabernetesLeaseLock) Create ¶
func (ll *ClabernetesLeaseLock) Create( ctx context.Context, ler resourcelock.LeaderElectionRecord, ) error
Create calls the embedded resourcelock.LeaseLock Create method and then adds labels to the newly created lease.
type Timers ¶
type Timers struct { // Duration of the leader election lease. Duration time.Duration // RenewDeadline for renewing leader election lease. RenewDeadline time.Duration // RetryPeriod window for leader election lease retries. RetryPeriod time.Duration }
Timers holds duration values for leader election/lease.