diff options
| author | Ivar Refsdal <ivar.refsdal@nsd.no> | 2021-09-23 13:12:12 +0200 |
|---|---|---|
| committer | Ivar Refsdal <ivar.refsdal@nsd.no> | 2021-09-23 13:12:12 +0200 |
| commit | cc9cc0ed52ca2d4fa82f2fe7dc5f17e61ced26f4 (patch) | |
| tree | 799139b85e82a59de4618ae98514fe7216e2b301 | |
| parent | Basic depends-on works for test queue (diff) | |
| download | fiinha-cc9cc0ed52ca2d4fa82f2fe7dc5f17e61ced26f4.tar.gz fiinha-cc9cc0ed52ca2d4fa82f2fe7dc5f17e61ced26f4.tar.xz | |
Basic depends-on seems to work
| -rw-r--r-- | src/com/github/ivarref/yoltq/impl.clj | 5 | ||||
| -rw-r--r-- | src/com/github/ivarref/yoltq/poller.clj | 8 | ||||
| -rw-r--r-- | src/com/github/ivarref/yoltq/report_queue.clj | 10 |
3 files changed, 14 insertions, 9 deletions
diff --git a/src/com/github/ivarref/yoltq/impl.clj b/src/com/github/ivarref/yoltq/impl.clj index 9811c93..a315545 100644 --- a/src/com/github/ivarref/yoltq/impl.clj +++ b/src/com/github/ivarref/yoltq/impl.clj @@ -60,9 +60,9 @@ (defn depends-on-waiting? [{:keys [conn]} - {:keys [id]}] + q-item] (let [db (d/db conn)] - (when-let [{:com.github.ivarref.yoltq/keys [opts]} (u/get-queue-item db id)] + (when-let [{:com.github.ivarref.yoltq/keys [opts]} (u/get-queue-item db (:id q-item))] (when-let [[q id :as depends-on] (:depends-on opts)] (when-not (d/q '[:find ?e . :in $ ?ext-id @@ -71,6 +71,7 @@ [?e :com.github.ivarref.yoltq/status :done]] db (pr-str [q id])) + (log/info "queue item" (str (:id q-item)) "is waiting on" depends-on) {:depends-on depends-on}))))) diff --git a/src/com/github/ivarref/yoltq/poller.clj b/src/com/github/ivarref/yoltq/poller.clj index 1f4e65d..28b158f 100644 --- a/src/com/github/ivarref/yoltq/poller.clj +++ b/src/com/github/ivarref/yoltq/poller.clj @@ -10,9 +10,11 @@ :error (u/get-error cfg q) :hung (u/get-hung cfg q))] (with-bindings (get item :bindings {}) - (some->> item - (i/take! cfg) - (i/execute! cfg))))) + (if (i/depends-on-waiting? cfg item) + nil + (some->> item + (i/take! cfg) + (i/execute! cfg)))))) (defn poll-queue! [running? diff --git a/src/com/github/ivarref/yoltq/report_queue.clj b/src/com/github/ivarref/yoltq/report_queue.clj index c6559bf..20e0a93 100644 --- a/src/com/github/ivarref/yoltq/report_queue.clj +++ b/src/com/github/ivarref/yoltq/report_queue.clj @@ -21,10 +21,12 @@ (try (let [{:com.github.ivarref.yoltq/keys [lock id status queue-name bindings]} (u/get-queue-item db-after id)] (with-bindings (or bindings {}) - (some->> - (u/prepare-processing db-after id queue-name lock status) - (i/take! cfg) - (i/execute! cfg)))) + (if (i/depends-on-waiting? cfg {:id id}) + nil + (some->> + (u/prepare-processing db-after id queue-name lock status) + (i/take! cfg) + (i/execute! cfg))))) (catch Throwable t (log/error t "unexpected error in process-poll-result!"))))))))) |
