Salutem
A health check library for sync / async health checks.
Install / Use
/learn @logicblocks/SalutemREADME
salutem
A system for defining and maintaining a collection of health checks.
salutem supports:
- both realtime and background checks
- a registry for storing, finding and resolving checks
- an asynchronous maintenance system for ensuring that the results of checks are kept up-to-date; and
- notifying via callbacks after checks are evaluated.
salutem also provides check function implementations for:
- data sources; and
- HTTP endpoints.
Install
Add the following to your project.clj file:
[io.logicblocks/salutem.core "0.1.8"]
Documentation
Usage
(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
{:salutem/timeout (salutem/duration 5 :seconds)}))
(salutem/with-check
(salutem/background-check :external-service
external-service-health-check-fn
{:salutem/time-to-re-evaluation (salutem/duration 30 :seconds)})))))
(def maintainer
(salutem/maintain registry-atom))
(salutem/resolve-checks @registry-atom)
; => {:database
; {:error :connection-failed
; :salutem/status :unhealthy
; :salutem/evaluated-at #time/instant"2021-08-18T23:39:29.234Z"}
; :external-service
; {:latency-ms 200,
; :salutem/status :healthy,
; :salutem/evaluated-at #time/instant"2021-08-18T23:39:10.383Z"}}
; ...5 seconds later...
(salutem/resolve-checks @registry-atom)
; => {:database
; {:error :connection-failed
; :salutem/status :unhealthy
; :salutem/evaluated-at #time/instant"2021-08-18T23:39:34.234Z"}
; :external-service
; {:latency-ms 200,
; :salutem/status :healthy,
; :salutem/evaluated-at #time/instant"2021-08-18T23:39:10.383Z"}}
(salutem/shutdown maintainer)
License
Copyright © 2023 LogicBlocks Maintainers
Distributed under the terms of the MIT License.
Related Skills
node-connect
347.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
