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.
(comp-dependencies sys c)Ids of all components this component depends on
Ids of all components this component depends on
(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.
(find-by-pred pred? o)Find all reference (Ref instances) in o
Find all reference (`Ref` instances) in o
(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`.
(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`.
(signal-keyseq sys handlers sig dest-state ks)Signal a number of keys in order
Signal a number of keys in order
(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.
(state sys)(state sys id)System or component state
System or component state
(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.
(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}}`
(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}}`
(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 :startIdempotent, 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`)
(value sys)System value, map of :makina/id -> :makina/value
System value, map of `:makina/id -> :makina/value`
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 |