Heartbeats scheduled things so that I can do health on them
This commit is contained in:
@@ -74,6 +74,10 @@
|
|||||||
invoices))
|
invoices))
|
||||||
|
|
||||||
(defn assert-no-conflicting [{:keys [invoice_number client_id vendor_id]}]
|
(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
|
(when (seq (d-invoices/find-conflicting {:invoice/invoice-number invoice_number
|
||||||
:invoice/vendor vendor_id
|
:invoice/vendor vendor_id
|
||||||
:invoice/client client_id}))
|
:invoice/client client_id}))
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
(:require
|
(:require
|
||||||
[auto-ap.datomic :refer [conn remove-nils]]
|
[auto-ap.datomic :refer [conn remove-nils]]
|
||||||
[auto-ap.logging :refer [info-event]]
|
[auto-ap.logging :refer [info-event]]
|
||||||
[auto-ap.utils :refer [dollars-0? dollars=]]
|
[auto-ap.utils :refer [dollars-0? dollars= heartbeat]]
|
||||||
[clj-time.core :as t]
|
|
||||||
[clj-time.coerce :as c]
|
[clj-time.coerce :as c]
|
||||||
|
[clj-time.core :as t]
|
||||||
[clojure.tools.logging :as log]
|
[clojure.tools.logging :as log]
|
||||||
[com.unbounce.dogstatsd.core :as statsd]
|
[com.unbounce.dogstatsd.core :as statsd]
|
||||||
[datomic.api :as d]
|
[datomic.api :as d]
|
||||||
@@ -423,5 +423,5 @@
|
|||||||
(log/error e)))))
|
(log/error e)))))
|
||||||
|
|
||||||
(mount/defstate touch-broken-ledger-worker
|
(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))
|
:stop (scheduler/stop touch-broken-ledger-worker))
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
(ns auto-ap.square.core
|
(ns auto-ap.square.core
|
||||||
(:require [auto-ap.datomic :refer [conn remove-nils]]
|
(:require [auto-ap.datomic :refer [conn remove-nils]]
|
||||||
|
[auto-ap.utils :refer [heartbeat]]
|
||||||
[auto-ap.time :as atime]
|
[auto-ap.time :as atime]
|
||||||
[clj-http.client :as client]
|
[clj-http.client :as client]
|
||||||
[clj-time.coerce :as coerce]
|
[clj-time.coerce :as coerce]
|
||||||
@@ -501,7 +502,7 @@
|
|||||||
(upsert-refunds client))))
|
(upsert-refunds client))))
|
||||||
|
|
||||||
(mount/defstate square-loader
|
(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))
|
: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
|
(defn by
|
||||||
([f xs]
|
([f xs]
|
||||||
@@ -79,3 +82,14 @@
|
|||||||
(f)
|
(f)
|
||||||
(finally
|
(finally
|
||||||
(reset! in-progress? false)))))))
|
(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