mirror of
https://github.com/penpot/penpot.git
synced 2025-01-23 23:18:48 -05:00
✨ Improve efficiency of thumbnails creation RPC methods
Moving the retry mechanism out of the transaction
This commit is contained in:
parent
82b10ecb87
commit
16a051d7e0
1 changed files with 13 additions and 12 deletions
|
@ -285,26 +285,29 @@
|
||||||
(sv/defmethod ::create-file-object-thumbnail
|
(sv/defmethod ::create-file-object-thumbnail
|
||||||
{::doc/added "1.19"
|
{::doc/added "1.19"
|
||||||
::doc/module :files
|
::doc/module :files
|
||||||
::climit/id :file-thumbnail-ops
|
::climit/id :file-thumbnail-ops/by-profile
|
||||||
::climit/key-fn ::rpc/profile-id
|
::climit/key-fn ::rpc/profile-id
|
||||||
|
|
||||||
|
::rtry/enabled true
|
||||||
|
::rtry/when rtry/conflict-exception?
|
||||||
|
|
||||||
::audit/skip true
|
::audit/skip true
|
||||||
::sm/params schema:create-file-object-thumbnail}
|
::sm/params schema:create-file-object-thumbnail}
|
||||||
|
|
||||||
[cfg {:keys [::rpc/profile-id file-id object-id media tag]}]
|
[cfg {:keys [::rpc/profile-id file-id object-id media tag]}]
|
||||||
|
(media/validate-media-type! media)
|
||||||
|
(media/validate-media-size! media)
|
||||||
|
|
||||||
(db/tx-run! cfg
|
(db/tx-run! cfg
|
||||||
(fn [{:keys [::db/conn] :as cfg}]
|
(fn [{:keys [::db/conn] :as cfg}]
|
||||||
(files/check-edition-permissions! conn profile-id file-id)
|
(files/check-edition-permissions! conn profile-id file-id)
|
||||||
(media/validate-media-type! media)
|
|
||||||
(media/validate-media-size! media)
|
|
||||||
|
|
||||||
(when-not (db/read-only? conn)
|
(when-not (db/read-only? conn)
|
||||||
(let [cfg (-> cfg
|
(let [cfg (-> cfg
|
||||||
(update ::sto/storage media/configure-assets-storage)
|
(update ::sto/storage media/configure-assets-storage)
|
||||||
(assoc ::rtry/when rtry/conflict-exception?)
|
(assoc ::rtry/when rtry/conflict-exception?)
|
||||||
(assoc ::rtry/max-retries 5)
|
(assoc ::rtry/max-retries 5)
|
||||||
(assoc ::rtry/label "create-file-object-thumbnail"))]
|
(assoc ::rtry/label "create-file-object-thumbnail"))]
|
||||||
(rtry/invoke cfg create-file-object-thumbnail!
|
(create-file-object-thumbnail! cfg file-id object-id media (or tag "frame")))))))
|
||||||
file-id object-id media (or tag "frame")))))))
|
|
||||||
|
|
||||||
;; --- MUTATION COMMAND: delete-file-object-thumbnail
|
;; --- MUTATION COMMAND: delete-file-object-thumbnail
|
||||||
|
|
||||||
|
@ -400,6 +403,8 @@
|
||||||
::audit/skip true
|
::audit/skip true
|
||||||
::climit/id :file-thumbnail-ops
|
::climit/id :file-thumbnail-ops
|
||||||
::climit/key-fn ::rpc/profile-id
|
::climit/key-fn ::rpc/profile-id
|
||||||
|
::rtry/enabled true
|
||||||
|
::rtry/when rtry/conflict-exception?
|
||||||
::sm/params [:map {:title "create-file-thumbnail"}
|
::sm/params [:map {:title "create-file-thumbnail"}
|
||||||
[:file-id ::sm/uuid]
|
[:file-id ::sm/uuid]
|
||||||
[:revn :int]
|
[:revn :int]
|
||||||
|
@ -409,10 +414,6 @@
|
||||||
(db/tx-run! cfg (fn [{:keys [::db/conn] :as cfg}]
|
(db/tx-run! cfg (fn [{:keys [::db/conn] :as cfg}]
|
||||||
(files/check-edition-permissions! conn profile-id file-id)
|
(files/check-edition-permissions! conn profile-id file-id)
|
||||||
(when-not (db/read-only? conn)
|
(when-not (db/read-only? conn)
|
||||||
(let [cfg (-> cfg
|
(let [cfg (update cfg ::sto/storage media/configure-assets-storage)
|
||||||
(update ::sto/storage media/configure-assets-storage)
|
media (create-file-thumbnail! cfg params)]
|
||||||
(assoc ::rtry/when rtry/conflict-exception?)
|
|
||||||
(assoc ::rtry/max-retries 5)
|
|
||||||
(assoc ::rtry/label "create-thumbnail"))
|
|
||||||
media (rtry/invoke cfg create-file-thumbnail! params)]
|
|
||||||
{:uri (files/resolve-public-uri (:id media))})))))
|
{:uri (files/resolve-public-uri (:id media))})))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue