clj-r2dbc.impl.transaction
Internal shared transaction helpers for middleware and interceptor execution.
Centralizes TransactionDefinition construction and rollback suppression so the
public middleware and interceptor namespaces can stay focused on their
respective composition models.
->tx-definition
(->tx-definition tx-opts)
Build a TransactionDefinition reification from a tx-opts map.
Args:
tx-opts - map with optional keys:
:isolation - isolation level keyword (see isolation-map).
:read-only? - boolean; default false.
:name - string savepoint or transaction name.
:lock-wait-timeout-ms - maximum time to wait for a lock, in ms.
Returns a reified TransactionDefinition.
Throws (synchronously):
ex-info when :isolation is present but not a key in isolation-map.begin-transaction-task
(begin-transaction-task conn tx-opts)
Return a Missionary task that begins a transaction on conn.
When tx-opts is non-empty, builds a TransactionDefinition from the map;
otherwise calls the no-arg beginTransaction overload.
Args:
conn - active R2DBC Connection.
tx-opts - transaction options map; pass {} for default transaction.isolation-map
Map of Clojure keywords to R2DBC IsolationLevel constants.
Supported keys:
:read-uncommitted, :read-committed, :repeatable-read, :serializable.
Used by ->tx-definition to translate the :isolation option.
rollback-with-suppression!
(rollback-with-suppression! conn root)
Return a Missionary task that rolls back the transaction on conn.
Secondary exceptions from rollback are suppressed on root via
.addSuppressed so the original cause is never lost.
missionary.Cancelled is re-thrown immediately without suppression.
Args:
conn - active R2DBC Connection.
root - the original Throwable causing the rollback, or nil.