Liking cljdoc? Tell your friends :D

lambdaisland.makina.system

Purely functional API for starting/stopping systems of components.

This is the Makina base layer, and is at your disposal when adapting it to custom use cases. See the app namespace for more convenience.

Purely functional API for starting/stopping systems of components.

This is the Makina base layer, and is at your disposal when adapting it to
custom use cases. See the `app` namespace for more convenience.
raw docstring

comp-dependenciesclj/s

(comp-dependencies sys c)

Ids of all components this component depends on

Ids of all components this component depends on
sourceraw docstring

componentclj/s

(component sys id)

Single component value

Single component value
sourceraw docstring

entries-by-typeclj/s

(entries-by-type sys t)
source

errorclj/s

(error sys)

If a component is in the error state, return the Error.

Generally there is never more than one, since system startup stops when an error is encountered.

If a component is in the error state, return the Error.

Generally there is never more than one, since system startup stops when an
error is encountered.
sourceraw docstring

find-by-predclj/s

(find-by-pred pred? o)

Find all reference (Ref instances) in o

Find all reference (`Ref` instances) in o
sourceraw docstring

find-handlerclj/s

(find-handler handlers t id sig)

Find a handler for a component of type t and id id and a given signal. The map of handlers is structured as t -> sig -> fn. For both the type t or the signal sig the key :default is checked as a fallback.

For a given type (or for the :default type) instead of the sig -> fn mapping a function may be supplied, which is equivalent to {:start fn}.

This first searches for a matching handler based on the type, then on the id, and then for type :default.

Find a handler for a component of type `t` and id `id` and a given signal. The
map of handlers is structured as `t -> sig -> fn`. For both the type `t` or
the signal `sig` the key `:default` is checked as a fallback.

For a given type (or for the `:default` type) instead of the `sig -> fn`
mapping a function may be supplied, which is equivalent to `{:start fn}`.

This first searches for a matching handler based on the type, then on the id,
and then for type `:default`.
sourceraw docstring

ids-by-typeclj/s

source

kahn-topo-sortclj/s

(kahn-topo-sort g)
source

no-incoming-edgesclj/s

(no-incoming-edges g ids)
source

ref?clj/s

(ref? o)
source

refset?clj/s

(refset? o)
source

replace-refsclj/s

(replace-refs sys v)
source

signal-keyclj/s

(signal-key sys handlers sig dest-state k)

Signal a single key. Does not recurse, i.e. it is the callers responsibility that dependent/dependee keys are signaled in topological (or reverse topological) order. You likely don't want to use this directly, but if you do [[expand-keys]] is your friend. See start/stop for higher level functions.

Takes the system (should be expanded as per system), and a handlers lookup map (see find-handler). Then transitions the component k to dest-state by invoking the sig handler. No-op if k is already in the dest-state.

Signal a single key. Does not recurse, i.e. it is the callers responsibility
that dependent/dependee keys are signaled in topological (or reverse
topological) order. You likely don't want to use this directly, but if you
do [[expand-keys]] is your friend. See [[start]]/[[stop]] for higher level
functions.

Takes the system (should be expanded as per [[system]]), and a handlers lookup
map (see [[find-handler]]). Then transitions the component `k` to `dest-state`
by invoking the `sig` handler. No-op if `k` is already in the `dest-state`.
sourceraw docstring

signal-keyseqclj/s

(signal-keyseq sys handlers sig dest-state ks)

Signal a number of keys in order

Signal a number of keys in order
sourceraw docstring

startclj/s

(start sys handlers)
(start sys handlers ks)

Start the system, running the start handler for some/all keys/components, in topological order.

Start the system, running the `start` handler for some/all keys/components, in
topological order.
sourceraw docstring

stateclj/s

(state sys)
(state sys id)

System or component state

System or component state
sourceraw docstring

stopclj/s

(stop sys handlers)
(stop sys handlers ks)

Stop the system, running the stop handler for some/all keys/components, in reverse topological order.

Stop the system, running the `stop` handler for some/all keys/components, in
reverse topological order.
sourceraw docstring

subgraphclj/s

(subgraph g ks)
source

sys-graph->clj/s

(sys-graph-> sys)

Graph of forward dependencies in the system: {dependent-id #{dependee-id}}

Graph of forward dependencies in the system: `{dependent-id #{dependee-id}}`
sourceraw docstring

sys-graph<-clj/s

(sys-graph<- sys)

Graph of backward dependencies in the system: {dependee-id #{dependent-id}}

Graph of backward dependencies in the system: `{dependee-id #{dependent-id}}`
sourceraw docstring

systemclj/s

(system config)

Expand a config map (id -> config), to a system map (id -> component), with all components stopped. In a system map each component is a map with keys

  • :makina/id The unique identifier of this component
  • :makina/type The type of this component, used to find handlers or expand refsets, defaults to the id
  • :makina/state The current state, defaults to :stopped
  • :makina/config The initial configuration, verbatim. Refs are not yet expanded.
  • :makina/value The current value for this component, initially this is the initial config + :makina/id + :makine/type, and is then replaced/transformed by signals like :start

Idempotent, will not expand keys that already look like components (have a :makina/state)

Expand a config map (`id -> config`), to a system map (`id -> component`), with
all components stopped. In a system map each component is a map with keys

- `:makina/id` The unique identifier of this component
- `:makina/type` The type of this component, used to find handlers or expand
   refsets, defaults to the `id`
- `:makina/state` The current state, defaults to `:stopped`
- `:makina/config` The initial configuration, verbatim. Refs are not yet expanded.
- `:makina/value` The current value for this component, initially this is the
  initial config + :makina/id + :makine/type, and is then replaced/transformed
  by signals like `:start`

Idempotent, will not expand keys that already look like components (have a `:makina/state`)
sourceraw docstring

valueclj/s

(value sys)

System value, map of :makina/id -> :makina/value

System value, map of `:makina/id -> :makina/value`
sourceraw docstring

values-by-typeclj/s

source

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close