Package-level declarations

Types

Link copied to clipboard
fun interface BackoffStrategy

A functional interface for calculating the delay before a transaction is retried due to deadlock.

Link copied to clipboard

A BackoffStrategy that implements binary exponential backoff. It returns a delay between 0 and 2**c - 1 inclusive, where c is the attempt number (starting at 1 for the delay after the first attempt). c is clamped at cMax. The delay is scaled by scale milliseconds.

Link copied to clipboard
class Database(dataSource: DataSource, deadlockDetector: DeadlockDetector = DefaultDeadlockDetector, backoffStrategy: BackoffStrategy = DEFAULT_BACKOFF_STRATEGY, attempts: Int = DEFAULT_ATTEMPTS)

A thin layer on top of the JDBC API that enforces the use of transactions, automatically retrying them on deadlock, and provides coroutine integration.

Link copied to clipboard
fun interface DeadlockDetector

A functional interface for checking if an SQLException represents a deadlock. There is no standard mechanism for representing deadlock errors, so vendor-specific implementations are required.

Link copied to clipboard

A vendor-neutral DeadlockDetector, which considers every SQLException to be a deadlock. One of the vendor-specific implementations should be used if possible, which will prevent non-deadlock errors (such as unique constraint violations) from being needlessly retried.

Link copied to clipboard

A BackoffStrategy with a fixed delay.

Link copied to clipboard

A DeadlockDetector implementation for H2.

Link copied to clipboard

A DeadlockDetector implementation for MySQL and MariaDB.

Link copied to clipboard

A DeadlockDetector implementation for PostgreSQL.

Link copied to clipboard

A DeadlockDetector implementation for SQLite.

Link copied to clipboard
fun interface Transaction<T>

A functional interface representing a single database transation.