LeaderElector
Class: LeaderElector
Defined in: kubernetes/src/operator/leader.ts:57
Leader election on a coordination.k8s.io Lease
Every retry period, the candidate creates the Lease, renews it when it holds it, or takes it over when it expired. Writes use the Lease resourceVersion: two candidates never both win. A leader that fails to renew stops leading at once, before its lease can expire for the others.
Constructors
Constructor
new LeaderElector(
api,options,callbacks):LeaderElector
Defined in: kubernetes/src/operator/leader.ts:85
Create a new LeaderElector instance
Parameters
api
ObjectCoordinationV1Api
the coordination API
options
the lease and timings
callbacks
leadership changes
Returns
LeaderElector
Properties
api
protectedapi:ObjectCoordinationV1Api
Defined in: kubernetes/src/operator/leader.ts:86
the coordination API
callbacks
protectedcallbacks:LeaderCallbacks
Defined in: kubernetes/src/operator/leader.ts:88
leadership changes
leading
leading:
boolean=false
Defined in: kubernetes/src/operator/leader.ts:77
Whether this candidate holds the lease
leaseDuration
protectedleaseDuration:number
Defined in: kubernetes/src/operator/leader.ts:69
Lease duration
options
protectedoptions:LeaderElectionOptions
Defined in: kubernetes/src/operator/leader.ts:87
the lease and timings
retryPeriod
protectedretryPeriod:number
Defined in: kubernetes/src/operator/leader.ts:73
Retry period
running
protectedrunning:boolean=false
Defined in: kubernetes/src/operator/leader.ts:65
Running
timer?
protectedoptionaltimer?:Timeout
Defined in: kubernetes/src/operator/leader.ts:61
Timer
Methods
attempt()
protectedattempt():Promise<void>
Defined in: kubernetes/src/operator/leader.ts:137
Acquire or renew the lease once, then schedule the next attempt
Returns
Promise<void>
release()
release():
Promise<void>
Defined in: kubernetes/src/operator/leader.ts:121
Clear the holder of the lease when this candidate holds it
Returns
Promise<void>
setLeading()
protectedsetLeading(leading):Promise<void>
Defined in: kubernetes/src/operator/leader.ts:155
Change the leadership, calling the callbacks
Parameters
leading
boolean
whether this candidate leads
Returns
Promise<void>
start()
start():
Promise<void>
Defined in: kubernetes/src/operator/leader.ts:98
Start competing for the lease
Returns
Promise<void>
once the first attempt is done
stop()
stop():
Promise<void>
Defined in: kubernetes/src/operator/leader.ts:106
Stop competing, releasing the lease when held
Returns
Promise<void>
tryAcquireOrRenew()
tryAcquireOrRenew():
Promise<boolean>
Defined in: kubernetes/src/operator/leader.ts:165
Create, renew or take over the lease
Returns
Promise<boolean>
whether this candidate holds the lease