clj-r2dbc.impl.connection.lifecycle
Connection lifecycle management for streaming plan flows.
When db is a ConnectionFactory: connection is acquired on flow start and
closed on termination (normal/error/cancel).
When db is already a Connection: the caller owns the lifecycle;
Connection.close() is NOT called.
This namespace owns stream connection lifecycle transitions.
Flow state machines (r2dbc-row-flow, r2dbc-chunk-flow) live in impl/execute/stream.
This namespace is an implementation detail; do not use from application code.
streaming-plan-flow
(streaming-plan-flow db sql params opts row-xf row-flow-fn)
Return a Missionary flow emitting transformed rows with end-to-end
demand-driven backpressure.
Connection lifecycle: when db is a ConnectionFactory, the connection is
acquired at flow start and closed on completion/error/cancellation.
When db is already a Connection, the caller owns the lifecycle.
row-flow-fn selects the per-row emission strategy:
r2dbc-row-flow - one row per deref() (default when not supplied).
r2dbc-chunk-flow - one ArrayList per fetch-size batch per deref().
Backpressure chain:
consumer m/reduce -> m/?> row-flow -> row-flow-fn.deref()
-> Subscription.request(fetch-size) -> R2DBC driver -> database cursor
Args:
db - ConnectionFactory, Connection, or ConnectableWithOpts.
sql - SQL string to execute.
params - sequential collection of bind parameters.
opts - options map (see execute for supported keys).
row-xf - 1-arity fn applied to each raw R2DBC Row before buffering.
row-flow-fn - fn [Publisher fetch-size xf] -> Missionary flow constructor.