From e142149a4282a669f3f95cb52f708d234a8ded23 Mon Sep 17 00:00:00 2001 From: Ivar Refsdal Date: Fri, 24 Sep 2021 10:59:06 +0200 Subject: Support :depends-on on queue level --- src/com/github/ivarref/yoltq/impl.clj | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/com/github/ivarref/yoltq/impl.clj b/src/com/github/ivarref/yoltq/impl.clj index adc169d..50441ff 100644 --- a/src/com/github/ivarref/yoltq/impl.clj +++ b/src/com/github/ivarref/yoltq/impl.clj @@ -37,8 +37,9 @@ queue-name payload opts] - (if-let [_ (get-in config [:handlers queue-name])] + (if-let [q-config (get-in config [:handlers queue-name])] (let [id (u/squuid) + depends-on (get q-config :depends-on (fn [_] nil)) str-bindings (->> (reduce (fn [o k] (assoc o (symbol k) (deref k))) {} @@ -51,11 +52,15 @@ :com.github.ivarref.yoltq/status u/status-init :com.github.ivarref.yoltq/payload (pr-str-safe :payload payload) :com.github.ivarref.yoltq/bindings str-bindings - :com.github.ivarref.yoltq/opts (pr-str-safe :opts (or opts {})) + :com.github.ivarref.yoltq/opts (pr-str-safe :opts + (merge + (when-let [deps (depends-on payload)] + {:depends-on deps}) + (or opts {}))) :com.github.ivarref.yoltq/lock (u/random-uuid) :com.github.ivarref.yoltq/tries 0 :com.github.ivarref.yoltq/init-time (u/now-ns)} - (when-let [[q ext-id] (:depends-on opts)] + (when-let [[q ext-id] (or (:depends-on opts) (depends-on payload))] (when-not (d/q '[:find ?e . :in $ ?ext-id :where -- cgit v1.2.3