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:72
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:73
the coordination API
callbacks
protectedcallbacks:LeaderCallbacks
Defined in: kubernetes/src/operator/leader.ts:75
leadership changes
leading
leading:
boolean=false
Defined in: kubernetes/src/operator/leader.ts:65
Whether this candidate holds the lease
leaseDuration
protectedleaseDuration:number
Defined in: kubernetes/src/operator/leader.ts:60
options
protectedoptions:LeaderElectionOptions
Defined in: kubernetes/src/operator/leader.ts:74
the lease and timings
retryPeriod
protectedretryPeriod:number
Defined in: kubernetes/src/operator/leader.ts:61
running
protectedrunning:boolean=false
Defined in: kubernetes/src/operator/leader.ts:59
timer?
protectedoptionaltimer?:Timeout
Defined in: kubernetes/src/operator/leader.ts:58
Methods
attempt()
protectedattempt():Promise<void>
Defined in: kubernetes/src/operator/leader.ts:117
Acquire or renew the lease once, then schedule the next attempt
Returns
Promise<void>
setLeading()
protectedsetLeading(leading):Promise<void>
Defined in: kubernetes/src/operator/leader.ts:135
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:85
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:93
Stop competing, releasing the lease when held
Returns
Promise<void>
tryAcquireOrRenew()
protectedtryAcquireOrRenew():Promise<boolean>
Defined in: kubernetes/src/operator/leader.ts:145
Create, renew or take over the lease
Returns
Promise<boolean>
whether this candidate holds the lease