Liking cljdoc? Tell your friends :D

dev.zeko.stube.async

Side-effecting registries that live in parallel to the conversation atom: timers, pub/sub, and the pending-flow baton.

Three independent state shapes:

atomshaperole
!pending-flows{cid → flow-id}one-shot baton between mount
and first SSE connect
!timers{cid → #{future}}scheduled future-fired events
!subscriptions{topic → {[cid iid] event}}live pub/sub routing

Delivery — both timer fires and publish! — calls back into a conversation via a dispatch function the server installs at startup with install-dispatch!. Keeping the dependency one-way (server requires async, async never requires server) avoids the circular require that would otherwise emerge from schedule-event! → dispatch! → kernel hook → schedule-event!.

Side-effecting registries that live in parallel to the conversation
atom: timers, pub/sub, and the pending-flow baton.

Three independent state shapes:

| atom            | shape                          | role                           |
|-----------------|--------------------------------|--------------------------------|
| `!pending-flows`| `{cid → flow-id}`              | one-shot baton between mount   |
|                 |                                | and first SSE connect          |
| `!timers`       | `{cid → #{future}}`            | scheduled future-fired events  |
| `!subscriptions`| `{topic → {[cid iid] event}}`  | live pub/sub routing           |

Delivery — both timer fires and `publish!` — calls back into a
conversation via a dispatch function the server installs at startup
with [[install-dispatch!]].  Keeping the dependency one-way (server
requires async, async never requires server) avoids the circular
require that would otherwise emerge from
`schedule-event! → dispatch! → kernel hook → schedule-event!`.
raw docstring

cancel-timers!clj

(cancel-timers! cid)

Cancel every scheduled future for cid and forget them.

Cancel every scheduled future for `cid` and forget them.
sourceraw docstring

forget-pending-flow!clj

(forget-pending-flow! cid)

Drop any pending entry for cid (used when a conversation ends before SSE ever attached).

Drop any pending entry for `cid` (used when a conversation ends
before SSE ever attached).
sourceraw docstring

install-dispatch!clj

(install-dispatch! f)

Called once by the server at namespace load (or by tests that need delivery without booting http) so timer and pub/sub deliveries can route events back into live conversations.

Called once by the server at namespace load (or by tests that need
delivery without booting http) so timer and pub/sub deliveries can
route events back into live conversations.
sourceraw docstring

pending-flowclj

(pending-flow cid)

Pop and return the pending flow id for cid, if any. After this call the cid no longer has a pending flow.

Pop and return the pending flow id for `cid`, if any.  After this
call the cid no longer has a pending flow.
sourceraw docstring

publish!clj

(publish! topic msg)

Asynchronously deliver msg to every live subscriber of topic. Returns the number of subscribers targeted.

Asynchronously deliver `msg` to every live subscriber of `topic`.
Returns the number of subscribers targeted.
sourceraw docstring

put-pending-flow!clj

(put-pending-flow! cid flow-id)

Record the root flow id a freshly-minted cid should boot when its first SSE connect arrives.

Record the root flow id a freshly-minted cid should boot when its
first SSE connect arrives.
sourceraw docstring

remove-subscriptions-for-cid!clj

(remove-subscriptions-for-cid! cid)

Drop every subscription owned by cid (used on conversation end).

Drop every subscription owned by `cid` (used on conversation end).
sourceraw docstring

reset-state!clj

(reset-state!)

Wipe every async registry. Intended for tests / REPL iteration.

Wipe every async registry.  Intended for tests / REPL iteration.
sourceraw docstring

schedule-event!clj

(schedule-event! {:keys [cid instance-id delay-ms event]})

Schedule a future event for a cid/iid. The future is cancelled when the conversation ends; if the instance disappears first, delivery is a no-op.

Schedule a future event for a cid/iid.  The future is cancelled when
the conversation ends; if the instance disappears first, delivery is a
no-op.
sourceraw docstring

subscribe!clj

(subscribe! {:keys [cid instance-id topic event]})

Subscribe cid/iid to topic; published values arrive as event.

Subscribe cid/iid to `topic`; published values arrive as `event`.
sourceraw docstring

subscriptionsclj

(subscriptions)

Snapshot of topic subscriptions, for tests/inspection.

Snapshot of topic subscriptions, for tests/inspection.
sourceraw docstring

unsubscribe!clj

(unsubscribe! {:keys [cid instance-id topic]})

Remove one cid/iid subscription. If topic is nil, remove all of the instance's subscriptions.

Remove one cid/iid subscription.  If `topic` is nil, remove all of the
instance's subscriptions.
sourceraw 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