Registry-based subscriber management for Concord's watch protocol.
Watchers register with a selector (key, prefix, or range) and receive matching events pushed to their mailbox. Supports bounded delivery queues with backpressure.
Usage
{:ok, watch_ref} = Concord.Sync.WatchHub.subscribe({:prefix, "/tasks/"}, self())
receive do
{:concord_event, ^watch_ref, event} -> handle(event)
end
:ok = Concord.Sync.WatchHub.unsubscribe(watch_ref)
Summary
Functions
Returns a specification to start this module under a supervisor.
Returns the count of active watchers.
Delivers matching events to all registered watchers. Called by the Dispatcher.
Subscribes a process to events matching the given selector.
Unsubscribes a watch by its reference.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec count() :: non_neg_integer()
Returns the count of active watchers.
@spec notify([Concord.Sync.Event.t()]) :: :ok
Delivers matching events to all registered watchers. Called by the Dispatcher.
@spec subscribe(Concord.KV.Selector.t(), pid(), keyword()) :: {:ok, reference()} | {:error, term()}
Subscribes a process to events matching the given selector.
Returns {:ok, watch_ref} where watch_ref is a unique reference.
@spec unsubscribe(reference()) :: :ok
Unsubscribes a watch by its reference.