object LeaderElection
- Alphabetic
- By Inheritance
- LeaderElection
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native() @HotSpotIntrinsicCandidate()
-
def
configMapLock(lockName: String, retryPolicy: Schedule[Any, Any, Unit] = defaultRetryPolicy, deleteLockOnRelease: Boolean = true): ZLayer[ContextInfo with ConfigMaps with Pods, Nothing, LeaderElection]
Simple leader election implementation
Simple leader election implementation
The algorithm tries creating a ConfigMap with a given name and attaches the Pod it is running in as an owner of the config map.
If the ConfigMap already exists the leader election fails and retries with exponential backoff. If it succeeds then it runs the inner effect.
When the code terminates normally the acquired ConfigMap gets released. If the whole Pod gets killed without releasing the resource, the registered ownership will make Kubernetes apply cascading deletion so eventually a new Pod can register the ConfigMap again.
-
def
customLeaderLock(lockName: String, retryPolicy: Schedule[Any, Any, Unit] = defaultRetryPolicy, deleteLockOnRelease: Boolean = true): ZLayer[ContextInfo with LeaderLockResources with Pods, Nothing, LeaderElection]
Simple leader election implementation based on a custom resource
Simple leader election implementation based on a custom resource
The algorithm tries creating a LeaderLock resource with a given name and attaches the Pod it is running in as an owner of the config map.
If the LeaderLock already exists the leader election fails and retries with exponential backoff. If it succeeds then it runs the inner effect.
When the code terminates normally the acquired LeaderLock gets released. If the whole Pod gets killed without releasing the resource, the registered ownership will make Kubernetes apply cascading deletion so eventually a new Pod can register the LeaderLock again.
This method requires the registration of the LeaderLock custom resource. As an alternative take a look at configMapLock().
-
val
defaultRetryPolicy: Schedule[Any, Any, Unit]
Default retry policy for acquiring the lock
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
fromLock: ZLayer[LeaderLock with ContextInfo, Nothing, LeaderElection]
Constructs a leader election interface using a given LeaderLock layer
Constructs a leader election interface using a given LeaderLock layer
For built-in leader election algorithms check configMapLock() and customLeaderLock().
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
leaseLock(lockName: String, leaseDuration: zio.Duration = 15.seconds, renewTimeout: zio.Duration = 10.seconds, retryPeriod: zio.Duration = 2.seconds): ZLayer[ContextInfo with Leases, Nothing, LeaderElection]
Lease based leader election implementation
Lease based leader election implementation
The leadership is not guaranteed to be held forever, the effect executed in runAsLeader may be interrupted. It is recommended to retry runAsLeader in these cases to try to reacquire the lease.
This is a reimplementation of the Go leaderelection package: https://github.com/kubernetes/client-go/blob/master/tools/leaderelection/leaderelection.go
- lockName
Name of the lease resource
- leaseDuration
Duration non-leader candidates must wait before acquiring leadership. This is measured against the time of the last observed change.
- renewTimeout
The maximum time a leader is allowed to try to renew its lease before giving up
- retryPeriod
Retry period for acquiring and renewing the lease
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
Deprecated Value Members
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] ) @Deprecated
- Deprecated