Skip to content
Exposed docs2.0

Exposed Ktor R2DBC Adapter

Latest stable Based on Exposed release 2.0.0

Coroutine-native R2DBC readiness, transaction, and error helpers for the selective Ktor boundary.

R2DBC consumers should not inherit blocking JDBC APIs or a cache lifecycle they do not use.

Use this adapter when the application owns an Exposed R2dbcDatabase and uses a coroutine-first persistence path.

implementation(platform("io.github.bluetape4k:bluetape4k-dependencies:<version>"))
implementation("io.github.bluetape4k.exposed:bluetape4k-exposed-ktor-r2dbc")

exposedKtorR2dbcReadinessProbe executes SELECT 1 in a cancellable suspendTransaction. Query timeout policy follows the caller-owned Exposed R2DBC configuration.

val probe = exposedKtorR2dbcReadinessProbe(r2dbcDatabase)
route.bluetape4kExposedHealthRoutes(listOf(probe))
  • Use exposedKtorR2dbcReadinessProbe for readiness.
  • Use ApplicationCall.exposedR2dbcTransaction for coroutine-native transactions.
  • Compose bluetape4kExposedR2dbcErrors() in StatusPages.

Keep transaction blocks suspend-native, propagate cancellation, and close the application-owned pool and database resources in one lifecycle owner.

This module depends on core and Exposed R2DBC only. JDBC and cache APIs are intentionally separate.

Component names and route paths follow core validation. R2DBC timeout behavior is inherited from the caller-owned database and driver.

R2DBC failures map to a fixed unavailable response. Cancellation is rethrown. A timeout or failed probe reports TIMEOUT or DOWN without driver details.

Export core readiness and transaction timers with bounded backend and outcome tags. Instrument the pool and driver separately when their metrics are available.

Run the R2DBC H2 suite and then PostgreSQL/MySQL integration paths. Cover cancellation, driver timeout, and shared-deadline ordering.

No selective R2DBC workshop is published in this 2.0.0 release line.

Driver support for query cancellation and timeout is implementation-specific; cooperative coroutine cancellation remains the request contract.