ConvergeLedger.WatchRegistry (Converge Ledger v0.1.2)

View Source

Registry for Watch stream subscribers.

Manages subscriptions to context updates. When entries are appended, this registry notifies all subscribers watching that context.

Summary

Functions

Returns a specification to start this module under a supervisor.

Notifies all subscribers of a new entry.

Starts the watch registry.

Subscribes the calling process to updates for a context.

Returns the number of subscribers for a context.

Unsubscribes the calling process from a context.

Types

context_id()

@type context_id() :: String.t()

subscriber()

@type subscriber() :: {pid(), reference()}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

notify(entry)

Notifies all subscribers of a new entry.

Called by the Store after appending an entry.

start_link(opts \\ [])

Starts the watch registry.

subscribe(context_id, key_filter \\ nil)

Subscribes the calling process to updates for a context.

Returns {:ok, ref} where ref is a monitor reference that will be used to clean up if the subscriber crashes.

subscriber_count(context_id)

Returns the number of subscribers for a context.

unsubscribe(context_id)

Unsubscribes the calling process from a context.