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}) {: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! (defn <transact!
([db tx-data] ([db tx-data]
(<transact! db tx-data nil 0xdeadbeef)) ;; TODO: timestamp! (<transact! db tx-data nil 0xdeadbeef)) ;; TODO: timestamp!
([db tx-data tx-meta now] ([db tx-data tx-meta now]
{:pre [(db? db)]} {:pre [(db? db)]}
(go-pair (s/in-transaction!
(let [current-tx (<? (<allocate-tx db))] (:sqlite-connection db)
(<? (<transact-tx-data db now #(go-pair
(map->TxReport (let [current-tx (<? (<allocate-tx db))
{:current-tx current-tx report (<? (<transact-tx-data db now
:tx-data [] (map->TxReport
:tempids {} {:current-tx current-tx
:tx-meta tx-meta}) tx-data)))))) :tx-data []
:tempids {}
:tx-meta tx-meta}) tx-data))]
(<? (<process-db-part db report))
report)))))