Liking cljdoc? Tell your friends :D

d-core.libs.pipeline

Railway-oriented CSP pipeline for Clojure core.async.

Stages execute in sequence; successful results pass to the next stage's input channel, while any failure (thrown exception or error return value) is immediately routed to a consolidated error channel. Returning nil filters/drops the item.

Railway-oriented CSP pipeline for Clojure core.async.

Stages execute in sequence; successful results pass to the next stage's
input channel, while any failure (thrown exception or error return value)
is immediately routed to a consolidated error channel. Returning `nil`
filters/drops the item.
raw docstring

channel-bufferclj

(channel-buffer {:keys [buffer buffer-type]})

Return a core.async buffer for channel config.

Supported keys:

  • :buffer (size, default 0)
  • :buffer-type (:fixed | :dropping | :sliding, default :fixed) A :buffer of 0 returns nil (unbuffered / rendezvous).
Return a core.async buffer for channel config.

Supported keys:
- :buffer (size, default 0)
- :buffer-type (:fixed | :dropping | :sliding, default :fixed)
A :buffer of 0 returns nil (unbuffered / rendezvous).
raw docstring

default-error?clj

(default-error? x)

Return true if x represents an error. Matches any Throwable, or a map with a non-nil, non-false :error key.

Return true if x represents an error.
Matches any Throwable, or a map with a non-nil, non-false :error key.
raw docstring

error-envelopeclj

(error-envelope stage-name input err)

Build a structured error envelope map.

Build a structured error envelope map.
raw docstring

into-pipeline!clj

(into-pipeline! items stages)
(into-pipeline! items stages opts)

Feed a collection of items through a pipeline and synchronously collect the results as {:ok [...] :err [...]}.

Supported options:

  • :timeout-ms (default 5000): abort if execution exceeds this duration
  • any options supported by pipeline
Feed a collection of items through a pipeline and synchronously collect
the results as `{:ok [...] :err [...]}`.

Supported options:
- :timeout-ms (default 5000): abort if execution exceeds this duration
- any options supported by `pipeline`
raw docstring

make-channelclj

(make-channel)
(make-channel buf-cfg)

Create a core.async channel with optional buffer configuration.

Create a core.async channel with optional buffer configuration.
raw docstring

make-intermediate-channelsclj

(make-intermediate-channels normalized-stages
                            default-buffer
                            default-buffer-type)

Build intermediate channels between consecutive stages.

Build intermediate channels between consecutive stages.
raw docstring

normalize-stageclj

(normalize-stage idx stage default-dispatch default-buffer default-buffer-type)

Normalize a stage definition (fn or map) into a standard stage map.

Normalize a stage definition (fn or map) into a standard stage map.
raw docstring

pipe->cljmacro

(pipe-> in-chan & stages-or-opts)

Convenience macro to construct a pipeline.

Usage: (pipe-> in-chan stage-fn1 stage-fn2) (pipe-> in-chan {:buffer 10} stage-fn1 stage-fn2)

Convenience macro to construct a pipeline.

Usage:
  (pipe-> in-chan stage-fn1 stage-fn2)
  (pipe-> in-chan {:buffer 10} stage-fn1 stage-fn2)
raw docstring

pipelineclj

(pipeline in-chan stages)
(pipeline in-chan stages opts)

Construct and start a railway-oriented CSP pipeline.

Arguments:

  • in-chan: input core.async channel
  • stages: vector/seq of stage functions or maps:
    • fn: (fn [msg] ...)
    • map: {:fn f, :name :custom-name, :dispatch :go|:thread, :buffer ...}
  • opts: optional map:
    • :out-chan: output channel for success results (defaults to unbuffered chan)
    • :err-chan: error channel for failures (defaults to unbuffered chan)
    • :buffer: default intermediate buffer size (default 0)
    • :buffer-type: default buffer type (:fixed, :dropping, :sliding)
    • :dispatch: default dispatch mode (:go or :thread, default :go)
    • :close-out?: whether to close out-chan when pipeline finishes (default true)
    • :close-err?: whether to close err-chan when all stages terminate (default true)

Returns: {:ok ok-chan, :err err-chan, :in in-chan, :stop! stop-fn}

Construct and start a railway-oriented CSP pipeline.

Arguments:
- in-chan: input core.async channel
- stages: vector/seq of stage functions or maps:
  - fn: `(fn [msg] ...)`
  - map: `{:fn f, :name :custom-name, :dispatch :go|:thread, :buffer ...}`
- opts: optional map:
  - :out-chan: output channel for success results (defaults to unbuffered chan)
  - :err-chan: error channel for failures (defaults to unbuffered chan)
  - :buffer: default intermediate buffer size (default 0)
  - :buffer-type: default buffer type (:fixed, :dropping, :sliding)
  - :dispatch: default dispatch mode (:go or :thread, default :go)
  - :close-out?: whether to close out-chan when pipeline finishes (default true)
  - :close-err?: whether to close err-chan when all stages terminate (default true)

Returns:
`{:ok ok-chan, :err err-chan, :in in-chan, :stop! stop-fn}`
raw docstring

safe-apply-stageclj

(safe-apply-stage stage-fn input error-pred)

Apply a stage function to input safely. Returns:

  • [:drop nil] when result is nil
  • [:err err] when an exception is thrown or error? matches
  • [:ok res] on successful return value.
Apply a stage function to input safely.
Returns:
- [:drop nil] when result is nil
- [:err err] when an exception is thrown or error? matches
- [:ok res] on successful return value.
raw docstring

start-go-stageclj

(start-go-stage {:keys [fn name error?] :as _stage}
                in-chan
                out-chan
                err-chan
                stop-chan
                should-close-out?
                on-done!)

Start a stage running in a core.async go-loop.

Start a stage running in a core.async go-loop.
raw docstring

start-stageclj

(start-stage stage
             in-chan
             out-chan
             err-chan
             stop-chan
             should-close-out?
             on-done!)

Dispatch stage execution based on its :dispatch strategy.

Dispatch stage execution based on its :dispatch strategy.
raw docstring

start-thread-stageclj

(start-thread-stage {:keys [fn name error?] :as _stage}
                    in-chan
                    out-chan
                    err-chan
                    stop-chan
                    should-close-out?
                    on-done!)

Start a stage running on a dedicated core.async thread.

Start a stage running on a dedicated core.async thread.
raw docstring

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