mirror of
https://github.com/penpot/penpot.git
synced 2025-02-02 04:19:08 -05:00
✨ Add facility for wrap a rpc method in a db transaction
This commit is contained in:
parent
4f48236fee
commit
3e11b4aa74
1 changed files with 8 additions and 0 deletions
|
@ -149,6 +149,13 @@
|
||||||
:hint "authentication required for this endpoint")
|
:hint "authentication required for this endpoint")
|
||||||
(f cfg params)))))
|
(f cfg params)))))
|
||||||
|
|
||||||
|
(defn- wrap-db-transaction
|
||||||
|
[_ f mdata]
|
||||||
|
(if (::db/transaction mdata)
|
||||||
|
(fn [cfg params]
|
||||||
|
(db/tx-run! cfg f params))
|
||||||
|
f))
|
||||||
|
|
||||||
(defn- wrap-audit
|
(defn- wrap-audit
|
||||||
[_ f mdata]
|
[_ f mdata]
|
||||||
(if (or (contains? cf/flags :webhooks)
|
(if (or (contains? cf/flags :webhooks)
|
||||||
|
@ -196,6 +203,7 @@
|
||||||
(defn- wrap-all
|
(defn- wrap-all
|
||||||
[cfg f mdata]
|
[cfg f mdata]
|
||||||
(as-> f $
|
(as-> f $
|
||||||
|
(wrap-db-transaction cfg $ mdata)
|
||||||
(cond/wrap cfg $ mdata)
|
(cond/wrap cfg $ mdata)
|
||||||
(retry/wrap-retry cfg $ mdata)
|
(retry/wrap-retry cfg $ mdata)
|
||||||
(climit/wrap cfg $ mdata)
|
(climit/wrap cfg $ mdata)
|
||||||
|
|
Loading…
Add table
Reference in a new issue