Liking cljdoc? Tell your friends :D

telsos.lib.call


create-async-callerclj/s

(create-async-caller {:keys [timeout-ms max-retries encoder decoder]
                      :or {max-retries 0 encoder identity decoder identity}})

Returns a fn (fn [transport arg] ...) that asynchronously calls (transport arg). The returned channel will receive:

  • the result (any value) on success
  • Throwable/js.Error on failure (encoding, transport, decoding, or timeout)

opts: :timeout-ms ms to wait for transport result (required) :max-retries max retry attempts on transport error or timeout (default 0) :encoder (fn [arg]) -> transformed-arg, called before transport (default identity) :decoder (fn [result]) -> transformed-result, called on success (default identity)

Both encoder and decoder may throw to abort the call. Retries on transport errors and timeouts only. Encoder/decoder failures are not retried. Note: on timeout, the transport channel is abandoned (not closed). The transport go-block may still complete — its result will be GC'd.

Returns a fn (fn [transport arg] ...) that asynchronously calls (transport arg).
The returned channel will receive:
- the result (any value) on success
- Throwable/js.Error on failure (encoding, transport, decoding, or timeout)

opts:
  :timeout-ms  ms to wait for transport result (required)
  :max-retries max retry attempts on transport error or timeout (default 0)
  :encoder     (fn [arg]) -> transformed-arg, called before transport (default identity)
  :decoder     (fn [result]) -> transformed-result, called on success (default identity)

Both encoder and decoder may throw to abort the call.
Retries on transport errors and timeouts only. Encoder/decoder failures are not retried.
Note: on timeout, the transport channel is abandoned (not closed). The
transport go-block may still complete — its result will be GC'd.
raw docstring

create-json-edn-callerclj/s

(create-json-edn-caller request-schema response-schema opts)

Builds an AsyncCaller that encodes a domain EDN request to JsonEdn before transport and decodes the JsonEdn response body back to domain EDN. Transport is passed directly to async-call at call time.

Uses the json-edn transformer (supports :uuid, :inst, :local-date, :keyword, :enum; keyword keys encoded to string keys in :map schemas).

encoder: encodes arg against request-schema → JsonEdn; invalid input throws ValidationException. decoder: receives the full response map from transport, decodes (:body response) against response-schema → domain EDN; invalid body throws ValidationException.

opts: same as create-async-caller (:timeout-ms, :max-retries).

Builds an AsyncCaller that encodes a domain EDN request to JsonEdn before
transport and decodes the JsonEdn response body back to domain EDN.
Transport is passed directly to async-call at call time.

Uses the json-edn transformer (supports :uuid, :inst, :local-date,
:keyword, :enum; keyword keys encoded to string keys in :map schemas).

encoder: encodes arg against request-schema → JsonEdn;
         invalid input throws ValidationException.
decoder: receives the full response map from transport, decodes
         (:body response) against response-schema → domain EDN;
         invalid body throws ValidationException.

opts: same as create-async-caller (:timeout-ms, :max-retries).
raw docstring

create-json-edn-handlerclj/s

(create-json-edn-handler status request-schema logic response-schema)

Builds a handler fn (fn [ctx request]) that decodes, dispatches, and encodes using the json-edn transformer (supports :uuid, :inst, :local-date, :keyword, :enum; string keys decoded to keywords in :map schemas).

  • Decodes (:body-params request) against request-schema; invalid input throws ValidationException → handler macro catches it → 400 response.
  • Calls (logic ctx decoded-request) → domain EDN.
  • Encodes the result against response-schema; invalid output throws ex-info → handler macro catches it → 500 response.
  • Returns {:status status :headers {} :body encoded-result} on success.
Builds a handler fn (fn [ctx request]) that decodes, dispatches, and encodes
using the json-edn transformer (supports :uuid, :inst, :local-date, :keyword,
:enum; string keys decoded to keywords in :map schemas).

- Decodes  (:body-params request) against request-schema;  invalid input
  throws ValidationException → handler macro catches it → 400 response.
- Calls    (logic ctx decoded-request) → domain EDN.
- Encodes  the result against response-schema; invalid output throws ex-info
  → handler macro catches it → 500 response.
- Returns  {:status status :headers {} :body encoded-result} on success.
raw docstring

create-std-json-handlerclj/s

(create-std-json-handler status decoder logic encoder)

create-test-transportclj/s

(create-test-transport handler ctx)

Returns a transport fn backed by handler for use in tests. Wraps arg as {:body-params arg} and calls (handler ctx request) in a go block.

Returns a transport fn backed by handler for use in tests.
Wraps arg as {:body-params arg} and calls (handler ctx request) in a go block.
raw docstring

error?clj/s

(error? x)

failing-alwaysclj/s

(failing-always handler)

Wraps handler so that every call returns an injected error value instead of delegating to handler. Use to stress-test behavior under persistent failure.

Wraps handler so that every call returns an injected error value instead of
delegating to handler. Use to stress-test behavior under persistent failure.
raw docstring

failing-randomlyclj/s

(failing-randomly n handler)

Wraps handler so that exactly one call per n-call window returns an injected error value instead of delegating to handler. The window always runs for exactly n calls; the single failing call within it is chosen at random. After n calls, a new fail position is chosen for the next window.

The returned fn returns an ex-info instance (not throws) on the failing call, matching the error-as-value convention expected by transports used with create-async-caller.

Not thread-safe; intended for single-threaded test harnesses.

Wraps handler so that exactly one call per n-call window returns an injected
error value instead of delegating to handler. The window always runs for
exactly n calls; the single failing call within it is chosen at random. After
n calls, a new fail position is chosen for the next window.

The returned fn returns an ex-info instance (not throws) on the failing call,
matching the error-as-value convention expected by transports used with
create-async-caller.

Not thread-safe; intended for single-threaded test harnesses.
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