diff --git a/src/common/datomish/transact.cljc b/src/common/datomish/transact.cljc index 718bcb47..dd2266e3 100644 --- a/src/common/datomish/transact.cljc +++ b/src/common/datomish/transact.cljc @@ -791,14 +791,14 @@ (-> report (assoc-in [:db-after] db-after))))) -(defn- ! token-chan (gensym "transactor-token")) (loop [] (when-let [token ( (! (:listener-source conn) report)) - report)))))] + ;; Default: process the transaction. + (do + (when @(:closed? conn) + ;; Drain enqueued transactions. + (raise "Connection is closed" {:error :transact/connection-closed})) + + (let [db (db conn) + in-transaction-fn + (case sentinel + :sentinel-fn + ;; This is a function that we'd like to run + ;; within a database transaction. See + ;; db/in-transaction! for details. + ;; The function is invoked with two arguments: + ;; the db and a function that takes (db, + ;; tx-data) and transacts it to return a + ;; TxReport. + ;; The function must return a TxReport. + ;; The function must not itself call + ;; `in-transaction!` or `! (:listener-source conn) report)) + report)))))] ;; Even when report is nil (transaction not committed), pair is non-nil. (>! result pair)) (>! token-chan token)