Show / Hide Table of Contents

Class LeaderElector

Inheritance
object
LeaderElector
Implements
IDisposable
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: k8s.LeaderElection
Assembly: KubernetesClient.dll
Syntax
public class LeaderElector : IDisposable

Constructors

View Source

LeaderElector(LeaderElectionConfig)

Declaration
public LeaderElector(LeaderElectionConfig config)
Parameters
Type Name Description
LeaderElectionConfig config

Methods

View Source

Dispose()

Declaration
public void Dispose()
View Source

Dispose(bool)

Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type Name Description
bool disposing
View Source

GetLeader()

Declaration
public string GetLeader()
Returns
Type Description
string
View Source

IsLeader()

Declaration
public bool IsLeader()
Returns
Type Description
bool
View Source

RunAndTryToHoldLeadershipForeverAsync(CancellationToken)

Tries to acquire leadership via a Kubernetes Lease resource. Will retry to acquire leadership again after leadership was lost.

Declaration
public Task RunAndTryToHoldLeadershipForeverAsync(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken

A token to cancel the operation.

Returns
Type Description
Task

A Task which completes only on cancellation

View Source

RunAsync(CancellationToken)

Tries to acquire leadership once via a Kubernetes Lease resource. Will complete the returned Task and not retry to acquire leadership again after leadership is lost once.

Declaration
[Obsolete("Replaced by RunUntilLeadershipLostAsync to encode behavior in method name.")]
public Task RunAsync(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken

A token to cancel the operation.

Returns
Type Description
Task

A Task representing the asynchronous operation.

See Also
RunUntilLeadershipLostAsync(CancellationToken)
View Source

RunUntilLeadershipLostAsync(CancellationToken)

Tries to acquire and hold leadership once via a Kubernetes Lease resource. Will complete the returned Task and not retry to acquire leadership again after leadership is lost once.

Declaration
public Task RunUntilLeadershipLostAsync(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken

A token to cancel the operation.

Returns
Type Description
Task

A Task representing the asynchronous operation.

Events

View Source

OnError

OnError is called when there is an error trying to determine leadership.

Declaration
public event Action<Exception> OnError
Event Type
Type Description
Action<Exception>
View Source

OnNewLeader

OnNewLeader is called when the client observes a leader that is not the previously observed leader. This includes the first observed leader when the client starts.

Declaration
public event Action<string> OnNewLeader
Event Type
Type Description
Action<string>
View Source

OnStartedLeading

OnStartedLeading is called when a LeaderElector client starts leading

Declaration
public event Action OnStartedLeading
Event Type
Type Description
Action
View Source

OnStoppedLeading

OnStoppedLeading is called when a LeaderElector client stops leading

Declaration
public event Action OnStoppedLeading
Event Type
Type Description
Action

Implements

IDisposable
  • View Source
In this article
Back to top Generated by DocFX