Skip to content
Leader docs0.4

etcd backend

Latest stable Based on Leader release 0.4.0

Library module

Preview: Validate API and operational behavior before production adoption.

Preview backend using etcd v3 leases and the jetcd Lock service for single and group election, with blocking, future, coroutine, and virtual-thread surfaces.

Use it when etcd is already a reliable control-plane dependency and lease semantics fit the workload.

Artifact: io.github.bluetape4k.leader:bluetape4k-leader-etcd

dependencies {
implementation(platform("io.github.bluetape4k:bluetape4k-dependencies:<version>"))
implementation("io.github.bluetape4k.leader:bluetape4k-leader-etcd")
}

Acquisition creates a lease and lock key; owner-safe release and extension use the returned token. The supplied jetcd client is caller-owned.

val elector = EtcdLeaderElector(
client,
EtcdLeaderElectionOptions(keyPrefix = "/apps/orders/leader")
)
elector.runIfLeader("reconcile") { reconcile() }

Use EtcdLeaderElector, suspend, virtual-thread, or group variants. Factories supply Core and framework integrations.

Use a dedicated prefix and least-privilege credentials. Keep actions idempotent and account for lease loss during pauses or partitions.

Spring can construct factories from a client. The etcd-reconciler example demonstrates a control-loop workload.

Configure endpoint in the caller-owned client, key prefix, wait/lease/minimum lease, retry delay, and cleanup timeout budget.

Contention skips. Lease grant, keepalive, lock, cleanup timeout, authentication, and transport failures propagate after classification.

Watch lease keepalive, request latency, compaction/cluster health, cleanup failures, and skipped work. Client closure belongs to the application.

Use a real etcd container for acquire/release, lease expiry, key encoding, cleanup timeout, group slots, and cancellation.

Run etcd-reconciler, then compare etcd leases with Consul sessions and Kubernetes Lease objects.

Preview API may evolve. etcd availability is now on the job path; a lease is not a business-side fencing token.

These diagrams are loaded directly from README assets published with the 0.4.0 release and pinned to its immutable commit. They describe this manual’s released structure and runtime flows, not later Snapshot changes. Select a preview to open the SVG at the same release commit.

leader-etcd architecture diagram

Release README: leader-etcd/README.md

Elector · Options · Stable guide