Turns Ramal's telemetry into PubSub messages, so that open inspectors update as branches change.
Add it to the host's supervision tree after the PubSub and Ramal.Supervisor:
children = [
{Phoenix.PubSub, name: MyApp.PubSub},
{Ramal.Supervisor, storage: Ramal.Storage.Postgres, repo: MyApp.Repo},
{RamalLive.Broadcaster, pubsub: MyApp.PubSub}
]It attaches telemetry handlers for the branch lifecycle events, [:ramal, :write, :capture] and the end of
[:ramal, :merge], and detaches them when it stops. A handler broadcasts {:ramal_live, branch_id, event} on the
topic of the branch's domain and nothing else, so no row data travels through the PubSub. Telemetry is node-local,
and so are branches (a branch lives on one node), which is why the broadcaster belongs in the tree of every node that
runs Ramal.Supervisor.
The inspector works without it, but only shows what was there when the page loaded or after an action made from the page, and says so.
Options
:pubsub- the host'sPhoenix.PubSubname. Required, and the same one given toramal_inspector/2.
Example
{:ok, _pid} = RamalLive.Broadcaster.start_link(pubsub: MyApp.PubSub)
RamalLive.Broadcaster.attached?(MyApp.PubSub)
#=> true
Summary
Functions
Whether a broadcaster for pubsub is attached on this node.
Returns a specification to start this module under a supervisor.
Starts the broadcaster. See the module doc for the options.
Functions
Whether a broadcaster for pubsub is attached on this node.
Example
RamalLive.Broadcaster.attached?(MyApp.PubSub)
#=> false
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec start_link(keyword()) :: GenServer.on_start()
Starts the broadcaster. See the module doc for the options.
Stops with {:already_attached, pubsub} when another broadcaster for the same PubSub is running, since every event
would be broadcast twice.