Heartbeats scheduled things so that I can do health on them
This commit is contained in:
@@ -74,6 +74,10 @@
|
||||
invoices))
|
||||
|
||||
(defn assert-no-conflicting [{:keys [invoice_number client_id vendor_id]}]
|
||||
(when-not vendor_id
|
||||
(assert-failure "Please specify a vendor."))
|
||||
(when-not invoice_number
|
||||
(assert-failure "Please specify an invoice."))
|
||||
(when (seq (d-invoices/find-conflicting {:invoice/invoice-number invoice_number
|
||||
:invoice/vendor vendor_id
|
||||
:invoice/client client_id}))
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
(:require
|
||||
[auto-ap.datomic :refer [conn remove-nils]]
|
||||
[auto-ap.logging :refer [info-event]]
|
||||
[auto-ap.utils :refer [dollars-0? dollars=]]
|
||||
[clj-time.core :as t]
|
||||
[auto-ap.utils :refer [dollars-0? dollars= heartbeat]]
|
||||
[clj-time.coerce :as c]
|
||||
[clj-time.core :as t]
|
||||
[clojure.tools.logging :as log]
|
||||
[com.unbounce.dogstatsd.core :as statsd]
|
||||
[datomic.api :as d]
|
||||
@@ -423,5 +423,5 @@
|
||||
(log/error e)))))
|
||||
|
||||
(mount/defstate touch-broken-ledger-worker
|
||||
:start (scheduler/every reconciliation-frequency touch-broken-ledger)
|
||||
:start (scheduler/every reconciliation-frequency (heartbeat touch-broken-ledger :touch-broken-ledger))
|
||||
:stop (scheduler/stop touch-broken-ledger-worker))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
(ns auto-ap.square.core
|
||||
(:require [auto-ap.datomic :refer [conn remove-nils]]
|
||||
[auto-ap.utils :refer [heartbeat]]
|
||||
[auto-ap.time :as atime]
|
||||
[clj-http.client :as client]
|
||||
[clj-time.coerce :as coerce]
|
||||
@@ -501,7 +502,7 @@
|
||||
(upsert-refunds client))))
|
||||
|
||||
(mount/defstate square-loader
|
||||
:start (scheduler/every (* 4 59 60 1000) upsert-all)
|
||||
:start (scheduler/every (* 4 59 60 1000) (heartbeat upsert-all :square-loading))
|
||||
:stop (scheduler/stop square-loader))
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
(ns auto-ap.utils)
|
||||
(ns auto-ap.utils
|
||||
#?@
|
||||
(:clj
|
||||
[(:require [clojure.tools.logging :as log])]))
|
||||
|
||||
(defn by
|
||||
([f xs]
|
||||
@@ -79,3 +82,14 @@
|
||||
(f)
|
||||
(finally
|
||||
(reset! in-progress? false)))))))
|
||||
|
||||
|
||||
(defn heartbeat [f id]
|
||||
(fn []
|
||||
#?(:clj
|
||||
(do
|
||||
(log/info "Heartbeat for " id)
|
||||
(f))
|
||||
|
||||
:cljs (do (println "Heartbeat for " id)
|
||||
(f)))))
|
||||
|
||||
Reference in New Issue
Block a user