Liking cljdoc? Tell your friends :D

manifold.lifecycle

Convention based lifecycle management of asynchronous chains. This implements a lightweight take on the ideas behind interceptors and similar libraries.

Notable differences are:

  • Manifold is the sole provided execution model for chains
  • No chain manipulation can occur
  • Guards and finalizer for steps are optional
  • Exceptions during lifecycle steps stop the execution
Convention based lifecycle management of asynchronous chains.
This implements a lightweight take on the ideas behind interceptors
and similar libraries.

Notable differences are:

- Manifold is the sole provided execution model for chains
- No chain manipulation can occur
- Guards and finalizer for steps are optional
- Exceptions during lifecycle steps stop the execution
raw docstring

error-handlers-forclj

(error-handlers-for id handlers)

A list of error handlers to try in sequence for a specific stage

A list of error handlers to try in sequence for a specific stage
sourceraw docstring

prepare-stageclj

(prepare-stage stage opts steps error-handlers)

Prepare a single stage, discard steps which do not have a handler for a specific stage.

Prepare a single stage, discard steps which do not have a handler
for a specific stage.
sourceraw docstring

runclj

(run init steps)
(run init opts steps)

Run a series of potentially asynchronous steps in sequence on an initial value (init0, threading each step's result to the next step as input.

Steps are maps or the following keys:

[:id :enter :leave :in :out :discard? :guard]
  • id is the unique ID for a step
  • enter is the function of the previous result in the enter stage
  • leave is the function of the previous result in the leave stage
  • in when present determines which path in the context will be fed to the handler. The handler is considered a function of the contex
  • out when present determines which path in the context to associate the result to, otherwise replaces the full context
  • discard? when present, runs the handler but pass the context untouched to the next step
  • guard is an optional predicate of the current context and previous preventing execution of the step when yielding false

In the three-arity version, an extra options maps can be provided, with the following keys:

[:augment :executor :initialize :stop-on]
  • augment is a function called on the context for each step, expected to yield an updated context. This can useful to perform timing tasks
  • executor a manifold executor to execute deferreds on
  • initialize is a function called on the context before running the lifecycle.
  • out a path in the context to retrieve as the final value out of the lifecycle
  • stop-on predicate which determines whether an early stop is mandated, for compatibility with interceptors terminate-when is synonymous.
Run a series of potentially asynchronous steps in sequence
on an initial value (`init`0, threading each step's result to
the next step as input.

Steps are maps or the following keys:

    [:id :enter :leave :in :out :discard? :guard]

- `id` is the unique ID for a step
- `enter` is the function of the previous result in the enter stage
- `leave` is the function of the previous result in the leave stage
- `in` when present determines which path in the context will
   be fed to the handler. The handler is considered a function
   of the contex
- `out` when present determines which path in the context to
   associate the result to, otherwise replaces the full context
- `discard?` when present, runs the handler but pass the context
   untouched to the next step
- `guard` is an optional predicate of the current context and previous
  preventing execution of the step when yielding false

In the three-arity version, an extra options maps can
be provided, with the following keys:

    [:augment :executor :initialize :stop-on]

- `augment` is a function called on the context for each step,
  expected to yield an updated context. This can useful to
  perform timing tasks
- `executor` a manifold executor to execute deferreds on
- `initialize` is a function called on the context before
  running the lifecycle.
- `out` a path in the context to retrieve as the final
   value out of the lifecycle
- `stop-on` predicate which determines whether an early stop is
  mandated, for compatibility with interceptors `terminate-when`
  is synonymous.
sourceraw docstring

stagesclj

Fixed list of stages to run through

Fixed list of stages to run through
sourceraw docstring

stepclj

(step enter)
(step id handlers & {:as params})

Convenience function to build a step map. Requires and ID and handler, and can be fed additional options

Convenience function to build a step map.
Requires and ID and handler, and can be fed
additional options
sourceraw docstring

step*clj

(step* id handlers {:keys [in out lens guard discard? error]})

Convenience function to build a step map. Requires and ID and handler, and can be fed additional options

Convenience function to build a step map.
Requires and ID and handler, and can be fed
additional options
sourceraw docstring

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

× close