Skip to content
Leader docs0.4

Getting started

Latest stable Based on Leader release 0.4.0

Validate skip-on-contention semantics locally, then replace only the elector with a distributed backend.

Import the central bluetape4k platform and add the core library. The central platform is the consumer-facing version authority; do not make the Leader BOM a second version choice.

implementation(platform("io.github.bluetape4k:bluetape4k-dependencies:<version>"))
implementation("io.github.bluetape4k.leader:bluetape4k-leader-core")
val elector = LocalLeaderElector()
val result = elector.runIfLeader("daily-report") { generateReport() }
if (result == null) logger.debug { "another contender ran daily-report" }

Keep the lock name stable across instances. A blank name is invalid. The default options wait up to 5 seconds, lease for 60 seconds, do not impose a minimum hold time, and do not enable auto-extension.

Replace LocalLeaderElector with a backend implementation while retaining the guarded action and its idempotency rules. Set waitTime to the amount of queuing you actually tolerate, and make leaseTime longer than normal execution plus jitter. Test two contenders, action failure, backend loss, and process restart before rollout.