splitting out background tasks

This commit is contained in:
2022-09-18 06:51:17 -07:00
parent 8b271e9e2a
commit 5017d9bc67
6 changed files with 287 additions and 244 deletions

View File

@@ -16,7 +16,6 @@
[datomic.api :as d]
[mount.core :as mount]
[unilog.context :as lc]
[yang.scheduler :as scheduler]
[clojure.set :as set])
(:import
(java.util UUID)
@@ -264,10 +263,6 @@
(defn refresh-current-balance []
(build-current-balance (bank-accounts-needing-refresh)))
(mount/defstate current-balance-worker
:start (scheduler/every (* 17 60 1000) (heartbeat refresh-current-balance "current-balance-cache"))
:stop (scheduler/stop current-balance-worker))
(defn get-client [context _ _]
(->graphql
(->> (d-clients/get-all)

View File

@@ -222,12 +222,6 @@
(log/warn "repairing " (count txes-missing-ledger-entries) " missing transactions, " (count invoices-missing-ledger-entries) " missing invoices that were missing ledger entries")
@(d/transact conn repairs)))))
(mount/defstate reconciliation-frequency :start (* 1000 60 60))
(mount/defstate ledger-reconciliation-worker
:start (scheduler/every reconciliation-frequency (heartbeat reconcile-ledger "reconcile-ledger"))
:stop (scheduler/stop ledger-reconciliation-worker))
(defn touch-transaction [e]
@(d/transact conn [[:db/retractEntity [:journal-entry/original-entity e]]])
@@ -465,7 +459,3 @@
:text "This process looks for unbalance ledger entries, or missing ledger entries"
:priority :low}
nil))
(mount/defstate touch-broken-ledger-worker
:start (scheduler/every reconciliation-frequency (heartbeat touch-broken-ledger "touch-broken-ledger"))
:stop (scheduler/stop touch-broken-ledger-worker))

View File

@@ -16,6 +16,8 @@
[auto-ap.background.metrics :as metrics]
[auto-ap.background.mail :as mail]
[auto-ap.jobs.square :as job-square]
[auto-ap.jobs.ledger-reconcile :as job-reconcile-ledger]
[auto-ap.jobs.current-balance-cache :as job-current-balance-cache]
[clojure.tools.logging :as log]
[config.core :refer [env]]
[mount.core :as mount]
@@ -91,6 +93,13 @@
(cond (= job "square-import-job")
(job-square/-main)
(= job "reconcile-ledger")
(job-reconcile-ledger/-main)
(= job "current-balance-cache")
(job-current-balance-cache/-main)
(= job "hello-world")
(do
(log/info "HELLO WORLD")
@@ -104,14 +113,11 @@
(not (env :run-web? )) (into [#'jetty
#'jetty-stats])
(not (env :run-background?)) (into [#'vendor/refresh-vendor-usages-worker
#'ledger/touch-broken-ledger-worker
#'mail/import-invoices
#'ledger/process-txes-worker
#'ledger/ledger-reconciliation-worker
#'requests/request-listener
#'sysco/sysco-invoice-importer
#'auto-ap.background.invoices/close-auto-invoices-worker
#'gq-clients/current-balance-worker
#'yodlee2/import-worker
#'yodlee2/account-worker
#'intuit/import-worker