mirror of
https://github.com/penpot/penpot.git
synced 2025-07-31 10:48:21 +02:00
♻️ Add API consistency fixes for task calling
Also adds a helper for calling tasks synchronously
This commit is contained in:
parent
aa1cf3e03a
commit
ec4260830c
19 changed files with 145 additions and 152 deletions
|
@ -34,6 +34,7 @@
|
|||
[app.util.blob :as blob]
|
||||
[app.util.services :as sv]
|
||||
[app.util.time :as dt]
|
||||
[app.worker :as wrk]
|
||||
[app.worker.runner]
|
||||
[clojure.java.io :as io]
|
||||
[clojure.spec.alpha :as s]
|
||||
|
@ -377,9 +378,9 @@
|
|||
([name]
|
||||
(run-task! name {}))
|
||||
([name params]
|
||||
(let [tasks (:app.worker/registry *system*)]
|
||||
(let [task-fn (get tasks (d/name name))]
|
||||
(task-fn params)))))
|
||||
(wrk/invoke! (-> *system*
|
||||
(assoc ::wrk/task name)
|
||||
(assoc ::wrk/params params)))))
|
||||
|
||||
(def sql:pending-tasks
|
||||
"select t.* from task as t
|
||||
|
|
|
@ -21,11 +21,10 @@
|
|||
(with-mocks [submit-mock {:target 'app.worker/submit! :return nil}]
|
||||
(let [prof (th/create-profile* 1 {:is-active true})
|
||||
res (th/run-task! :process-webhook-event
|
||||
{:props
|
||||
{:app.loggers.webhooks/event
|
||||
{:type "command"
|
||||
:name "create-project"
|
||||
:props {:team-id (:default-team-id prof)}}}})]
|
||||
{:event
|
||||
{:type "command"
|
||||
:name "create-project"
|
||||
:props {:team-id (:default-team-id prof)}}})]
|
||||
|
||||
(t/is (= 0 (:call-count @submit-mock)))
|
||||
(t/is (nil? res)))))
|
||||
|
@ -35,11 +34,10 @@
|
|||
(let [prof (th/create-profile* 1 {:is-active true})
|
||||
whk (th/create-webhook* {:team-id (:default-team-id prof)})
|
||||
res (th/run-task! :process-webhook-event
|
||||
{:props
|
||||
{:app.loggers.webhooks/event
|
||||
{:type "command"
|
||||
:name "create-project"
|
||||
:props {:team-id (:default-team-id prof)}}}})]
|
||||
{:event
|
||||
{:type "command"
|
||||
:name "create-project"
|
||||
:props {:team-id (:default-team-id prof)}}})]
|
||||
|
||||
(t/is (= 1 (:call-count @submit-mock)))
|
||||
(t/is (nil? res)))))
|
||||
|
@ -52,9 +50,8 @@
|
|||
:name "create-project"
|
||||
:props {:team-id (:default-team-id prof)}}
|
||||
res (th/run-task! :run-webhook
|
||||
{:props
|
||||
{:app.loggers.webhooks/event evt
|
||||
:app.loggers.webhooks/config whk}})]
|
||||
{:event evt
|
||||
:config whk})]
|
||||
|
||||
(t/is (= 1 (:call-count @http-mock)))
|
||||
|
||||
|
@ -75,9 +72,8 @@
|
|||
:name "create-project"
|
||||
:props {:team-id (:default-team-id prof)}}
|
||||
res (th/run-task! :run-webhook
|
||||
{:props
|
||||
{:app.loggers.webhooks/event evt
|
||||
:app.loggers.webhooks/config whk}})]
|
||||
{:event evt
|
||||
:config whk})]
|
||||
|
||||
(t/is (= 1 (:call-count @http-mock)))
|
||||
|
||||
|
@ -94,14 +90,12 @@
|
|||
;; RUN 2 times more
|
||||
|
||||
(th/run-task! :run-webhook
|
||||
{:props
|
||||
{:app.loggers.webhooks/event evt
|
||||
:app.loggers.webhooks/config whk}})
|
||||
{:event evt
|
||||
:config whk})
|
||||
|
||||
(th/run-task! :run-webhook
|
||||
{:props
|
||||
{:app.loggers.webhooks/event evt
|
||||
:app.loggers.webhooks/config whk}})
|
||||
{:event evt
|
||||
:config whk})
|
||||
|
||||
|
||||
(let [rows (th/db-query :webhook-delivery {:webhook-id (:id whk)})]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue