0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-11 23:31:21 -05:00

🔥 Remove unused jobs code (obsolete).

This commit is contained in:
Andrey Antukh 2020-02-05 23:52:57 +01:00
parent 358136b840
commit 9373296fd4

View file

@ -1,38 +0,0 @@
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) 2016-2019 Andrey Antukh <niwi@niwi.nz>
(ns uxbox.util.jobs
"Scheduled jobs facilities."
(:require
[clojure.tools.logging :as log]
[clojure.spec.alpha :as s]
[promesa.core :as p]
[vertx.timers :as vt]
[vertx.util :as vu]))
(defn schedule!
[vsm f {:keys [::interval] :as options}]
(s/assert var? f)
(let [system (vu/resolve-system vsm)
state (atom nil)
taskfn (fn wrapped-task []
(-> (p/do! (@f options))
(p/catch (fn [err]
(log/error err "Error on executing the task")
nil))
(p/then (fn [_]
(let [tid (vt/schedule-once! vsm interval wrapped-task)]
(reset! state tid)
nil)))))
tid (vt/schedule-once! vsm interval taskfn)]
(reset! state tid)
(reify
java.lang.AutoCloseable
(close [this]
(locking this
(when-let [timer-id (deref state)]
(.cancelTimer system timer-id)
(reset! state nil)))))))