clj-r2dbc.interceptor
Data-driven interceptor extensions for the clj-r2dbc pipeline.
Interceptors are plain maps with four optional phase keys:
:enter - called before execution with the context map; may return an
updated context (sync) or a Missionary task (async).
:leave - called after successful execution in reverse enter order.
:error - called on failure; receives the context with :clj-r2dbc/error.
:name - optional identifier for debugging.
Interceptors compose as a stack: enter runs FIFO, leave and error run LIFO.
Pass a seq of interceptor maps via the :interceptors option.
Provides:
logging-interceptor - logs SQL timing, row count, and errors.
transaction-interceptor - factory; wraps execution in begin/commit/rollback.logging-interceptor
added in 0.1
Interceptor that logs SQL execution timing and row/update counts.
Attaches a start timestamp on :enter, logs success on :leave, and
logs errors on :error. Params are intentionally omitted (redacted).
transaction-interceptor
added in 0.1
(transaction-interceptor & {:as tx-opts})
Return an interceptor map that wraps execution in begin/commit/rollback.
:enter begins a transaction. :leave commits. :error rolls back.
When :clj-r2dbc/in-transaction? is already true in the context,
all three phases pass through (join semantics).
Args:
tx-opts - (optional) transaction options map; defaults to {}.
:isolation - isolation level keyword
(see impl/transaction 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.
Accepts a map, keyword arguments, or both.
Returns an interceptor map with :name, :enter, :leave, and :error keys.
Example:
(transaction-interceptor)
(transaction-interceptor {:isolation :serializable})
(transaction-interceptor :isolation :serializable)