(bidi-async-handler f
&
{:keys [in-ch-fn out-ch-fn]
:or {in-ch-fn (fn* [] (async/chan 16))
out-ch-fn (fn* [] (async/chan 16))}})Wraps (fn [in-ch out-ch]) as a :bidi handler.
Incoming client messages arrive on in-ch; it is closed when the client
signals completion or an error occurs. Put response messages onto out-ch
and close it to end the stream.
Options:
:in-ch-fn — zero-arg fn returning the incoming channel (default: #(async/chan 16)):out-ch-fn — zero-arg fn returning the outgoing channel (default: #(async/chan 16))Wraps `(fn [in-ch out-ch])` as a `:bidi` handler. Incoming client messages arrive on `in-ch`; it is closed when the client signals completion or an error occurs. Put response messages onto `out-ch` and close it to end the stream. Options: * `:in-ch-fn` — zero-arg fn returning the incoming channel (default: `#(async/chan 16)`) * `:out-ch-fn` — zero-arg fn returning the outgoing channel (default: `#(async/chan 16)`)
(client-stream-async-handler f
&
{:keys [in-ch-fn out-ch-fn]
:or {in-ch-fn (fn* [] (async/chan 16))
out-ch-fn (fn* [] (async/chan 1))}})Wraps (fn [in-ch out-ch]) as a :client-stream handler.
Incoming client messages arrive on in-ch; it is closed when the client
signals completion or an error occurs. Put response messages onto out-ch
and close it to end the stream.
Options:
:in-ch-fn — zero-arg fn returning the incoming channel (default: #(async/chan 16)):out-ch-fn — zero-arg fn returning the outgoing channel (default: #(async/chan 1))Wraps `(fn [in-ch out-ch])` as a `:client-stream` handler. Incoming client messages arrive on `in-ch`; it is closed when the client signals completion or an error occurs. Put response messages onto `out-ch` and close it to end the stream. Options: * `:in-ch-fn` — zero-arg fn returning the incoming channel (default: `#(async/chan 16)`) * `:out-ch-fn` — zero-arg fn returning the outgoing channel (default: `#(async/chan 1)`)
(complete! observer)(complete! observer msg)Signals successful stream completion to the client. With 2 args, sends
msg first then completes — convenience for unary and single-response
server-streaming handlers.
Signals successful stream completion to the client. With 2 args, sends `msg` first then completes — convenience for unary and single-response server-streaming handlers.
(error! observer throwable)Signals an error to the client via observer. throwable must be a
java.lang.Throwable.
Signals an error to the client via `observer`. `throwable` must be a `java.lang.Throwable`.
(send! observer msg)Sends msg to the client via observer.
Sends `msg` to the client via `observer`.
(server-stream-async-handler f
&
{:keys [out-ch-fn]
:or {out-ch-fn (fn* [] (async/chan 16))}})Wraps (fn [request out-ch]) as a :server-stream handler.
The user fn receives the request and a core.async channel. Put any
number of response messages onto out-ch then close it to end the stream.
Options:
:out-ch-fn — zero-arg fn returning the outgoing channel (default: #(async/chan 16))Wraps `(fn [request out-ch])` as a `:server-stream` handler. The user fn receives the request and a `core.async` channel. Put any number of response messages onto `out-ch` then close it to end the stream. Options: * `:out-ch-fn` — zero-arg fn returning the outgoing channel (default: `#(async/chan 16)`)
(stream-observer {:keys [on-next on-error on-completed]})Returns a StreamObserver backed by callback fns supplied as a map:
:on-next — (fn [msg]) — called for each incoming message:on-error — (fn [throwable]) — called on stream error:on-completed — (fn []) — called when the client signals completionAll keys are optional; unset callbacks are no-ops.
Returns a `StreamObserver` backed by callback fns supplied as a map: * `:on-next` — `(fn [msg])` — called for each incoming message * `:on-error` — `(fn [throwable])` — called on stream error * `:on-completed` — `(fn [])` — called when the client signals completion All keys are optional; unset callbacks are no-ops.
(unary-async-handler f
&
{:keys [out-ch-fn]
:or {out-ch-fn (fn* [] (async/chan 1))}})Wraps (fn [request out-ch]) as a :unary handler.
The user fn receives the request and a core.async channel. Put exactly
one response message onto out-ch then close it. Closing out-ch
completes the stream.
Options:
:out-ch-fn — zero-arg fn returning the outgoing channel (default: #(async/chan 1))Wraps `(fn [request out-ch])` as a `:unary` handler. The user fn receives the request and a `core.async` channel. Put exactly one response message onto `out-ch` then close it. Closing `out-ch` completes the stream. Options: * `:out-ch-fn` — zero-arg fn returning the outgoing channel (default: `#(async/chan 1)`)
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 |