clj-r2dbc.impl.execute.pipeline
Interceptor pipeline runner for clj-r2dbc.
Provides:
run-pipeline - executes an interceptor chain with enter/execute/leave phases.
This namespace is an implementation detail; do not use from application code.
run-pipeline
(run-pipeline ctx interceptors execute-fn)(run-pipeline ctx interceptors execute-fn opts)
Execute an interceptor chain with enter/execute/leave phases.
Args:
ctx - the initial context map.
interceptors - sequential collection of interceptor maps.
execute-fn - 1-arity fn [ctx] -> task; performs the core operation.
opts - (optional) map; :max-interceptor-depth overrides the default 64.
Returns a Missionary task resolving to the final context map on success,
or rejecting with the original throwable on failure.
Pipeline phases:
1. Enter: each interceptor's :enter handler runs in queue order (FIFO).
2. Execute: execute-fn is called with the context after all :enter handlers.
3. Leave: each interceptor's :leave handler runs in reverse order (LIFO).
On failure in any phase, run-error-stage is invoked with the appropriate
stack of interceptors for cleanup. The original throwable is always re-thrown
after error handlers complete.
Each stage is isolated in a nested m/sp:
JVM restriction: recur cannot appear in tail position inside try.
Cancellation: each m/? is a Missionary cancellation checkpoint.
Throws (synchronously):
ex-info :clj-r2dbc/limit-exceeded when interceptor chain exceeds
:max-interceptor-depth (default 64).
missionary.Cancelled is never swallowed - it propagates through error handlers
and triggers physical Subscription.cancel() on R2DBC publishers.