salutem.core.registry

Provides constructors, query functions and resolution functions for registries.

all-checks

(all-checks registry)

Returns the set of checks present in the registry.

check-names

(check-names registry)

Returns the set of check names present in the registry.

empty-registry

(empty-registry)

Constructs an empty registry which can be populated using with-check and with-cached-result.

find-cached-result

(find-cached-result registry check-name)

Finds the cached result for the check with the given name in the registry. Returns nil if no result can be found or if the check does not exist.

find-check

(find-check registry check-name)

Finds the check with the given name in the registry. Returns nil if no check can be found.

outdated-checks

(outdated-checks registry)

Returns the set of checks that are currently outdated in the registry based on the type of the check and the cached results available.

See salutem.results/outdated? for details on which it means for a check to be outdated.

resolve-check

(resolve-check registry check-name)(resolve-check registry check-name context)(resolve-check registry check-name context callback-fn)

Resolves a result for the check of the given name in the registry.

If the check is a background check and there is a cached result available, it is returned. If no cached result is available, the check is evaluated in order to obtain a result to return.

If the check is a realtime check, it is always evaluated in order to obtain a result to return and caching is not used.

Optionally takes a context map containing arbitrary context required by the check in order to run and passed to the check function as the first argument.

By default, the check is resolved synchronously. If a callback function is provided, the function starts resolution asynchronously, returns immediately and invokes the callback function with the result once available.

resolve-checks

(resolve-checks registry)(resolve-checks registry context)(resolve-checks registry context callback-fn)

Resolves all checks in the registry, returning a map of check names to results.

Checks requiring re-evaluation are evaluated in parallel such that this function should take about as long as the slowest check (assuming IO is the dominant blocker).

Optionally takes a context map containing arbitrary context required by checks in order to run and passed to the check functions as the first argument.

By default, the checks are resolved synchronously. If a callback function is provided, the function starts resolution asynchronously, returns immediately and invokes the callback function with the results once available.

See resolve-check for details on how each check is resolved.

with-cached-result

(with-cached-result registry check-name result)

Adds the result for the check with the given name to the registry, returning a new registry.

with-check

(with-check registry check)

Adds the check to the registry, returning a new registry.