Process <transact! in a transaction; add hook for processing :db.part/db changes.

This commit is contained in:
Nick Alexander 2016-07-14 18:05:07 -07:00
parent 44411f0e94
commit 54b1d268fa

View file

@ -327,16 +327,27 @@
{:error :transact/syntax, :tx-data entity})
)))))
(defn <process-db-part
"Transactions may add idents, install new partitions, and install new schema attributes. Handle
them, atomically, here."
[db report]
(go-pair
nil))
(defn <transact!
([db tx-data]
(<transact! db tx-data nil 0xdeadbeef)) ;; TODO: timestamp!
([db tx-data tx-meta now]
{:pre [(db? db)]}
(go-pair
(let [current-tx (<? (<allocate-tx db))]
(<? (<transact-tx-data db now
(s/in-transaction!
(:sqlite-connection db)
#(go-pair
(let [current-tx (<? (<allocate-tx db))
report (<? (<transact-tx-data db now
(map->TxReport
{:current-tx current-tx
:tx-data []
:tempids {}
:tx-meta tx-meta}) tx-data))))))
:tx-meta tx-meta}) tx-data))]
(<? (<process-db-part db report))
report)))))