A component composition library.
A component composition library.
(apply-components f rec sub-components operation-name on-f)
Execute a function on a sequence of components from a record.
Exceptions are caught and propagate with a :system
data element
that contains the partially updated system component, a :component
key that is the keyword for the component that caused the exception,
and :incomplete
which is a sequence of keywords for the components
where the operation was not completed.
Execute a function on a sequence of components from a record. Exceptions are caught and propagate with a `:system` data element that contains the partially updated system component, a `:component` key that is the keyword for the component that caused the exception, and `:incomplete` which is a sequence of keywords for the components where the operation was not completed.
(comp-on-f f1 f2)
Compose two functions for use with an on-start or on-finish function.
Compose two functions for use with an on-start or on-finish function.
(defsystem record-name components & body)
Macro to build a system defrecord out of components
, a sequence
of keywords that specify the sub-components. The record will
implement Startable, Stoppable and Queryable by calling the protocol
methods on each of the components. The start
method calls the
sub-components in the specified order. The stop
method calls the
sub-components in the reverse order.
An option map may be supplied after the sub-component vector.
The :depends key can be used to specify components that depend on each system component. The value must be a map where the keys are keywords and the values are either a sequence of (system component) keywords, or a map from (system component) keyword to a keyword specifying the key to be updated in that component. A simple keyword is used for the case where the sub-component keyword matches the component key. A map entry is used when the keyword needs to be translated.
{:depends {:sub-comp2 [:sub-comp1] :sub-comp3 {:sub-comp1 :comp1}}}
The :on-start and :on-stop key can be used to pass functions that are called after the sub-component is operated on. Each function must take component, and sub-component keyword, and return a possibly modified component map.
{:on-start {:sub-comp1 (update-subcomponent :sub-comp2) :sub-comp2 #(assoc-in %1 [:sub-comp3 :comp1] %3)}}
The :depends map is used to generate :on-start and :on-stop functions, which will override any specified :on-start and :on-stop values.
A body can be supplied as used by defrecord, to implement extra protocols on the system.
Macro to build a system defrecord out of `components`, a sequence of keywords that specify the sub-components. The record will implement Startable, Stoppable and Queryable by calling the protocol methods on each of the components. The `start` method calls the sub-components in the specified order. The `stop` method calls the sub-components in the reverse order. An option map may be supplied after the sub-component vector. The :depends key can be used to specify components that depend on each system component. The value must be a map where the keys are keywords and the values are either a sequence of (system component) keywords, or a map from (system component) keyword to a keyword specifying the key to be updated in that component. A simple keyword is used for the case where the sub-component keyword matches the component key. A map entry is used when the keyword needs to be translated. {:depends {:sub-comp2 [:sub-comp1] :sub-comp3 {:sub-comp1 :comp1}}} The :on-start and :on-stop key can be used to pass functions that are called after the sub-component is operated on. Each function must take component, and sub-component keyword, and return a possibly modified component map. {:on-start {:sub-comp1 (update-subcomponent :sub-comp2) :sub-comp2 #(assoc-in %1 [:sub-comp3 :comp1] %3)}} The :depends map is used to generate :on-start and :on-stop functions, which will override any specified :on-start and :on-stop values. A body can be supplied as used by defrecord, to implement extra protocols on the system.
(dependents depends)
Invert the specified dependencies.
Invert the specified dependencies.
(process-depends {:keys [depends] :as options})
Convert :depends into :on-start and :on-stop function declarations.
Convert :depends into :on-start and :on-stop function declarations.
(queryable? x)
Predicate for testing whether `x` satisfies the Queryable protocol. ## Function Signatures - Any -> Any
Predicate for testing whether x
satisfies the Queryable protocol.
Predicate for testing whether `x` satisfies the Queryable protocol. ## Function Signatures - schema/Any -> schema/Any
(start component)
Start a component. ## Function Signatures - Any -> Any
Start a component. ## Function Signatures - schema/Any -> schema/Any
(startable? x)
Predicate for testing whether `x` satisfies the Startable protocol. ## Function Signatures - Any -> Any
Predicate for testing whether x
satisfies the Startable protocol.
Predicate for testing whether `x` satisfies the Startable protocol. ## Function Signatures - schema/Any -> schema/Any
(status component)
Ask a component for its status. ## Function Signatures - Any -> Any
Ask a component for its status. ## Function Signatures - schema/Any -> schema/Any
(stop component)
Stop a component. ## Function Signatures - Any -> Any
Stop a component. ## Function Signatures - schema/Any -> schema/Any
(stoppable? x)
Predicate for testing whether `x` satisfies the Stoppable protocol. ## Function Signatures - Any -> Any
Predicate for testing whether x
satisfies the Stoppable protocol.
Predicate for testing whether `x` satisfies the Stoppable protocol. ## Function Signatures - schema/Any -> schema/Any
(update-components component-specs)
Returns a function to update the system components given by
component-specs
.
, with a sub-component, assuming the component acts like a map.
Can be used as a value in an :on-start option map in defrecord to get components updated with their started values.
Returns a function to update the system components given by `component-specs`. , with a sub-component, assuming the component acts like a map. Can be used as a value in an :on-start option map in defrecord to get components updated with their started values. ## Function Signatures - (schema/either [schema/Keyword] #:schema{Keyword schema/Keyword}) -> (=> schema/Any schema/Any schema/Keyword)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close