Exposed R2DBC backend
Latest stable Based on Leader release 0.4.0
Library module
Problem
Section titled “Problem”Implements coroutine single and group election with Exposed R2DBC transactions while sharing SQL ownership rules with JDBC.
When to use it
Section titled “When to use it”Choose it for coroutine-first R2DBC services; choose JDBC when surrounding APIs are blocking or virtual-thread based.
Coordinates
Section titled “Coordinates”Artifact: io.github.bluetape4k.leader:bluetape4k-leader-exposed-r2dbc
dependencies { implementation(platform("io.github.bluetape4k:bluetape4k-dependencies:<version>")) implementation("io.github.bluetape4k.leader:bluetape4k-leader-exposed-r2dbc")}Core concepts
Section titled “Core concepts”Suspend transactions perform conditional writes with expiry and owner tokens. Cancellation must clean up only the lease owned by that call.
Quick start
Section titled “Quick start”val elector = ExposedR2DbcSuspendLeaderElector(database)elector.runIfLeader("projection-refresh") { refreshProjection() }API by task
Section titled “API by task”Use suspend single/group electors, R2dbcDatabase extensions, factories, initializer, and suspend history sink.
Recommended patterns
Section titled “Recommended patterns”Keep acquire/use/release in structured scope, do not hide JDBC blocking calls inside it, and migrate the shared schema first.
Integrations
Section titled “Integrations”Can share a namespace with JDBC when database, schema, and release match. Spring and Ktor consume the suspend factory/elector.
Configuration
Section titled “Configuration”Tune wait, lease, retry, schema, R2DBC pool, statement timeout, and lifecycle ownership.
Failure modes
Section titled “Failure modes”Contention returns null; cancellation rethrows after owner-safe cleanup; connection and transaction failures propagate.
Operations
Section titled “Operations”Observe acquisition latency, pool queue time, retries, cancellation cleanup, and database load.
Testing
Section titled “Testing”Use a real R2DBC database for two-client contention, group slots, expiry, and cancellation during acquire/action.
Workshops and learning path
Section titled “Workshops and learning path”Compare JDBC, then run migration-gate and the Ktor example to see lifecycle integration.
Limitations
Section titled “Limitations”R2DBC removes blocked threads, not database round trips or database availability risk.
Release diagrams
Section titled “Release diagrams”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 exposed r2dbc Class Structure diagram
Section titled “leader exposed r2dbc Class Structure diagram”Release README: leader-exposed-r2dbc/README.md
