Liking cljdoc? Tell your friends :D

com.palletops.leaven

A component composition library.

A component composition library.
raw docstring

apply-componentsclj/s

(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.
sourceraw docstring

comp-on-fclj/s

(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.
sourceraw docstring

defsystemcljmacro

(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.
sourceraw docstring

dependentsclj

(dependents depends)

Invert the specified dependencies.

Invert the specified dependencies.
sourceraw docstring

process-dependsclj

(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.
sourceraw docstring

queryable?clj/s≠

(queryable? x)
clj

Predicate for testing whether x satisfies the Queryable protocol.

Function Signatures

  • Any -> Any
Predicate for testing whether `x` satisfies the Queryable protocol.

## Function Signatures

  - Any -> Any
cljs

Predicate for testing whether x satisfies the Queryable protocol.

Function Signatures

  • schema/Any -> schema/Any
Predicate for testing whether `x` satisfies the Queryable protocol.

## Function Signatures

  - schema/Any -> schema/Any
sourceraw docstring

startclj/s≠

(start component)
clj

Start a component.

Function Signatures

  • Any -> Any
Start a component.

## Function Signatures

  - Any -> Any
cljs

Start a component.

Function Signatures

  • schema/Any -> schema/Any
Start a component.

## Function Signatures

  - schema/Any -> schema/Any
sourceraw docstring

startable?clj/s≠

(startable? x)
clj

Predicate for testing whether x satisfies the Startable protocol.

Function Signatures

  • Any -> Any
Predicate for testing whether `x` satisfies the Startable protocol.

## Function Signatures

  - Any -> Any
cljs

Predicate for testing whether x satisfies the Startable protocol.

Function Signatures

  • schema/Any -> schema/Any
Predicate for testing whether `x` satisfies the Startable protocol.

## Function Signatures

  - schema/Any -> schema/Any
sourceraw docstring

statusclj/s≠

(status component)
clj

Ask a component for its status.

Function Signatures

  • Any -> Any
Ask a component for its status.

## Function Signatures

  - Any -> Any
cljs

Ask a component for its status.

Function Signatures

  • schema/Any -> schema/Any
Ask a component for its status.

## Function Signatures

  - schema/Any -> schema/Any
sourceraw docstring

stopclj/s≠

(stop component)
clj

Stop a component.

Function Signatures

  • Any -> Any
Stop a component.

## Function Signatures

  - Any -> Any
cljs

Stop a component.

Function Signatures

  • schema/Any -> schema/Any
Stop a component.

## Function Signatures

  - schema/Any -> schema/Any
sourceraw docstring

stoppable?clj/s≠

(stoppable? x)
clj

Predicate for testing whether x satisfies the Stoppable protocol.

Function Signatures

  • Any -> Any
Predicate for testing whether `x` satisfies the Stoppable protocol.

## Function Signatures

  - Any -> Any
cljs

Predicate for testing whether x satisfies the Stoppable protocol.

Function Signatures

  • schema/Any -> schema/Any
Predicate for testing whether `x` satisfies the Stoppable protocol.

## Function Signatures

  - schema/Any -> schema/Any
sourceraw docstring

update-componentsclj/s

(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.

Function Signatures

  • (schema/either [schema/Keyword] #:schema{Keyword schema/Keyword}) -> (=> schema/Any schema/Any schema/Keyword)
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)
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close