Provides an asynchronous maintenance pipeline for maintaining up-to-date results for the checks in a registry.
Provides an asynchronous maintenance pipeline for maintaining up-to-date results for the checks in a registry.
(evaluator dependencies evaluation-channel)
(evaluator dependencies evaluation-channel result-channel)
(maintain registry-store)
(maintain registry-store
{:keys [context interval trigger-channel evaluation-channel
result-channel updater-result-channel notifier-result-channel
callback-fns]
:or {context {}
interval (t/new-duration 200 :millis)
trigger-channel (async/chan (async/sliding-buffer 1))
evaluation-channel (async/chan 10)
result-channel (async/chan 10)
updater-result-channel (async/chan 10)
notifier-result-channel (async/chan 10)
callback-fns []}})
Constructs and starts a maintenance pipeline to maintain up-to-date results for the checks in the registry in the provided registry store atom.
The maintenance pipeline consists of a number of independent processes:
The maintenance pipeline can be configured via an optional map which can contain the following options:
:context
: a map containing arbitrary context required by checks in
order to run and passed to the check functions as the first
argument; defaults to an empty map:interval
: a [[duration]] describing the wait interval between
attempts to refresh the results in the registry; defaults to 200
milliseconds:callback-fns
: a sequence of arity-2 functions, with the first
argument being a check and the second argument being a result, which
are called whenever a new result is available for a check; empty by
default:trigger-channel
: the channel on which trigger messages are sent, to
indicate that a refresh of the registry should be attempted, defaults
to a channel with a sliding buffer of length 1, i.e., in the case of a
long running attempt, all but the latest trigger message will be dropped
from the channel:evaluation-channel
: the channel on which messages requesting
evaluation of checks are sent, defaults to a channel with a buffer of
size 10:result-channel
: the channel on which results are placed after
evaluation, defaults to a channel with a buffer of size 10:updater-result-channel
: a tap of the result-channel
which sends
result messages on to the updater, defaults to a channel with a buffer
of size 10:notifier-result-channel
: a tap of the result-channel
which sends
result messages on to the notifier, defaults to a channel with a buffer
of size 10If the context map contains a :logger
key with a
cartus.core/Logger
value, the maintenance pipeline will emit a number of log events
throughout operation.
Returns the maintenance pipeline which can be passed to shutdown
in
order to stop operation.
Constructs and starts a maintenance pipeline to maintain up-to-date results for the checks in the registry in the provided registry store atom. The maintenance pipeline consists of a number of independent processes: - a _maintainer_ which triggers an attempt to refresh the results periodically, - a _refresher_ which requests evaluation of each outdated check on each refresh attempt, - an _evaluator_ which evaluates outdated checks to obtain a fresh result, - an _updater_ which updates the registry store atom with fresh check results, - a _notifier_ which calls callback functions when fresh check results are available. The maintenance pipeline can be configured via an optional map which can contain the following options: - `:context`: a map containing arbitrary context required by checks in order to run and passed to the check functions as the first argument; defaults to an empty map - `:interval`: a [[duration]] describing the wait interval between attempts to refresh the results in the registry; defaults to 200 milliseconds - `:callback-fns`: a sequence of arity-2 functions, with the first argument being a check and the second argument being a result, which are called whenever a new result is available for a check; empty by default - `:trigger-channel`: the channel on which trigger messages are sent, to indicate that a refresh of the registry should be attempted, defaults to a channel with a sliding buffer of length 1, i.e., in the case of a long running attempt, all but the latest trigger message will be dropped from the channel - `:evaluation-channel`: the channel on which messages requesting evaluation of checks are sent, defaults to a channel with a buffer of size 10 - `:result-channel`: the channel on which results are placed after evaluation, defaults to a channel with a buffer of size 10 - `:updater-result-channel`: a tap of the `result-channel` which sends result messages on to the updater, defaults to a channel with a buffer of size 10 - `:notifier-result-channel`: a tap of the `result-channel` which sends result messages on to the notifier, defaults to a channel with a buffer of size 10 If the context map contains a `:logger` key with a [`cartus.core/Logger`](https://logicblocks.github.io/cartus/cartus.core.html#var-Logger) value, the maintenance pipeline will emit a number of log events throughout operation. Returns the maintenance pipeline which can be passed to [[shutdown]] in order to stop operation.
(maintainer dependencies registry-store context interval trigger-channel)
(maintainer dependencies
registry-store
context
interval
trigger-channel
shutdown-channel)
(notifier dependencies callbacks result-channel)
(refresher dependencies trigger-channel)
(refresher dependencies trigger-channel evaluation-channel)
(shutdown maintenance-pipeline)
Shuts down the maintenance pipeline preventing further updates to the registry.
Shuts down the maintenance pipeline preventing further updates to the registry.
(updater dependencies registry-store result-channel)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close