A system for defining and maintaining a collection of health checks.
salutem supports:
Add the following to your project.clj file:
[io.logicblocks/salutem.core "0.1.0-RC14"]
(require '[salutem.core :as salutem])
(defn database-health-check-fn
  [context callback-fn]
  (callback-fn
    (salutem/unhealthy
      {:error :connection-failed})))
(defn external-service-health-check-fn
  [context callback-fn]
  (callback-fn
    (salutem/healthy
      {:latency-ms 200})))
(def registry-atom
  (atom
    (-> (salutem/empty-registry)
      (salutem/with-check
        (salutem/realtime-check :database
          database-health-check-fn
          {:timeout (salutem/duration 5 :seconds)}))
      (salutem/with-check
        (salutem/background-check :external-service
          external-service-health-check-fn
          {:time-to-re-evaluation (salutem/duration 30 :seconds)})))))
(def maintainer
  (salutem/maintain registry-atom))
(salutem/resolve-checks @registry-atom)
; => {:database
;      {:error :connection-failed
;       :status :unhealthy
;       :evaluated-at #time/instant"2021-08-18T23:39:29.234Z"}
;     :external-service 
;      {:latency-ms 200,
;       :status :healthy,
;       :evaluated-at #time/instant"2021-08-18T23:39:10.383Z"}}
; ...5 seconds later...
(salutem/resolve-checks @registry-atom)
; => {:database
;      {:error :connection-failed
;       :status :unhealthy
;       :evaluated-at #time/instant"2021-08-18T23:39:34.234Z"}
;     :external-service 
;      {:latency-ms 200,
;       :status :healthy,
;       :evaluated-at #time/instant"2021-08-18T23:39:10.383Z"}}
(salutem/shutdown maintainer)
Copyright © 2021 LogicBlocks Maintainers
Distributed under the terms of the MIT License.
Can you improve this documentation? These fine people already did:
Toby Clemson & Jordan RobinsonEdit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs | 
| ← | Move to previous article | 
| → | Move to next article | 
| Ctrl+/ | Jump to the search field |