much more background process tracking

This commit is contained in:
2022-06-22 10:43:37 -07:00
parent 480066b202
commit 1db8d7a52c
15 changed files with 379 additions and 486 deletions

View File

@@ -1,24 +1,26 @@
(ns auto-ap.graphql.clients
(:require [auto-ap.datomic :refer [audit-transact conn remove-nils]]
[auto-ap.datomic.clients :as d-clients]
[auto-ap.graphql.utils :refer [->graphql assert-admin can-see-client? is-admin?]]
[auto-ap.utils :refer [by]]
[auto-ap.yodlee.core :refer [in-memory-cache]]
[auto-ap.routes.queries :as q]
[auto-ap.square.core :as square]
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
[clj-time.coerce :as coerce]
[clojure.string :as str]
[unilog.context :as lc]
[clojure.tools.logging :as log]
[datomic.api :as d]
[clojure.java.io :as io]
[amazonica.aws.s3 :as s3]
#_{:clj-kondo/ignore [:unused-namespace]}
[yang.scheduler :as scheduler]
[mount.core :as mount])
(:import [org.apache.commons.codec.binary Base64]
java.util.UUID))
(:require
[amazonica.aws.s3 :as s3]
[auto-ap.datomic :refer [audit-transact conn remove-nils]]
[auto-ap.datomic.clients :as d-clients]
[auto-ap.graphql.utils
:refer [->graphql assert-admin can-see-client? is-admin?]]
[auto-ap.routes.queries :as q]
[auto-ap.square.core :as square]
[auto-ap.utils :refer [by heartbeat]]
[auto-ap.yodlee.core :refer [in-memory-cache]]
[clj-time.coerce :as coerce]
[clojure.java.io :as io]
[clojure.string :as str]
[clojure.tools.logging :as log]
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
[datomic.api :as d]
[mount.core :as mount]
[unilog.context :as lc]
[yang.scheduler :as scheduler])
(:import
(java.util UUID)
(org.apache.commons.codec.binary Base64)))
(defn assert-client-code-is-unique [code]
(when (seq (d/query {:query {:find '[?id]
@@ -245,15 +247,10 @@
(map first)))))
(defn refresh-current-balance []
(lc/with-context {:source "current-balance-cache"}
(try
(log/info "Refreshing running balance cache")
(build-current-balance (bank-accounts-needing-refresh))
(catch Exception e
(log/error e)))))
(build-current-balance (bank-accounts-needing-refresh)))
(mount/defstate current-balance-worker
:start (scheduler/every (* 17 60 1000) refresh-current-balance)
:start (scheduler/every (* 17 60 1000) (heartbeat refresh-current-balance "current-balance-cache"))
:stop (scheduler/stop current-balance-worker))
(defn get-client [context _ _]

View File

@@ -8,16 +8,16 @@
[auto-ap.graphql.utils
:refer [->graphql <-graphql assert-admin assert-can-see-client result->page]]
[auto-ap.parse.util :as parse]
[auto-ap.utils :refer [by dollars=]]
[auto-ap.pdf.ledger :refer [print-pnl print-balance-sheet]]
[auto-ap.pdf.ledger :refer [print-balance-sheet print-pnl]]
[auto-ap.utils :refer [by dollars= heartbeat]]
[clj-time.coerce :as coerce]
[clj-time.core :as t]
[clojure.tools.logging :as log]
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
[datomic.api :as d]
[mount.core :as mount]
[unilog.context :as lc]
[yang.scheduler :as scheduler]
[clj-time.core :as t]))
[yang.scheduler :as scheduler]))
(mount/defstate running-balance-cache
:start (atom {}))
@@ -525,16 +525,11 @@
(defn refresh-running-balance-cache []
(lc/with-context {:source "running-balance-cache"}
(try
(log/info "Refreshing running balance cache")
(build-running-balance-cache)
(catch Exception e
(log/error e)))))
(build-running-balance-cache))
(mount/defstate running-balance-cache-worker
:start (scheduler/every (* 15 60 1000) refresh-running-balance-cache)
:start (scheduler/every (* 15 60 1000) (heartbeat refresh-running-balance-cache "running-balance-cache"))
:stop (scheduler/stop running-balance-cache-worker))