Skip to content
Leader docs0.4

DynamoDB backend

Latest stable Based on Leader release 0.4.0

Library module

Preview: Validate API and operational behavior before production adoption.

Preview backend using DynamoDB conditional writes and logical lease expiry. It supports blocking, async, virtual-thread, coroutine, and group election.

Use it for AWS workloads that already depend on DynamoDB and need region-local coordination without another service.

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

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

The table has string partition key lockName; rows store owner IDs, millisecond leaseExpiry, and second ttl. Correctness uses leaseExpiry; DynamoDB TTL is cleanup metadata only.

val elector = DynamoDbLeaderElector(
dynamoDbClient,
DynamoDbLeaderElectionOptions(tableName = "bluetape4k_leader_locks")
)
elector.runIfLeader("export") { exportData() }

Choose sync, async-client suspend, virtual-thread, or group classes. The application provisions the table and owns both AWS clients.

Use PAY_PER_REQUEST or capacity sized for contention, stable key prefixes, idempotent actions, and conditional owner checks for extend/release.

Spring auto-configuration can use caller-owned AWS clients. The dynamodb-export example shows a complete job lifecycle.

Configure table name, key prefix, wait/lease/minimum lease, retry behavior, and TTL attribute. Enable TTL on numeric ttl for cleanup.

Conditional-check contention skips; SDK, IAM, throttling, and network failures propagate. TTL deletion delay must never decide whether acquisition is safe.

Monitor consumed capacity, throttles, conditional failures, latency, stale-row count, and clock skew. Keep the table lifecycle in infrastructure code.

Use DynamoDB Local/Testcontainers for two-client acquire, expiry, stale-owner release, group slots, suspend and virtual-thread paths.

Run dynamodb-export and compare the AWS operational model with Redis or SQL backends.

Preview status and eventually executed TTL cleanup require conservative operations. Cross-region coordination and global-table conflict behavior are outside this contract.

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-dynamodb architecture diagram

Release README: leader-dynamodb/README.md

leader-dynamodb conditional lease sequence

Section titled “leader-dynamodb conditional lease sequence”

leader-dynamodb conditional lease sequence

Release README: leader-dynamodb/README.md

Elector · Options · Stable guide