Dust.CallbackRegistry (dustlayer v0.1.1)

Copy Markdown View Source

Summary

Functions

Look up a registered subscription by ref. Returns {worker_pid, max_queue_size, on_resync, mode} or nil if no subscription with that ref exists.

Find all matching subscriptions for a store/path. Returns a list of {worker_pid, ref, max_queue_size, on_resync, mode} tuples.

Register a callback for a store/pattern with options.

Functions

lookup(table, ref)

Look up a registered subscription by ref. Returns {worker_pid, max_queue_size, on_resync, mode} or nil if no subscription with that ref exists.

match(table, store, path)

Find all matching subscriptions for a store/path. Returns a list of {worker_pid, ref, max_queue_size, on_resync, mode} tuples.

new()

register(table, store, pattern, callback, opts \\ [])

Register a callback for a store/pattern with options.

Options:

  • :max_queue_size - maximum pending events before the subscription is dropped (default: 1000)
  • :on_resync - callback invoked with %{error: :resync_required, ref: ref} when the subscription is dropped due to backpressure
  • :mode - which events to deliver to this subscription:
    • :all (default) - optimistic for own writes, committed for others' (the historical SDK behaviour: exactly one event per write).
    • :committed - only committed events, including the server echo of your own writes (so the callback always sees a store_seq).
    • :optimistic - only the optimistic local events; never the committed echoes.

Each registration spawns a Dust.CallbackWorker process that receives events asynchronously. The dispatcher checks the worker's mailbox length before sending; if it exceeds max_queue_size, the subscription is unregistered and on_resync fires.

unregister(table, ref)