Behaviour for broadcasting ExAgent.Events.
ExAgent never depends on a concrete PubSub implementation. The default is
ExAgent.PubSub.None (no side-effects, for one-shot use and tests that don't
observe events). ExAgent.PubSub.Local ships an in-process Registry-backed
implementation that works out of the box. ExAgent.PubSub.Phoenix delegates
to Phoenix.PubSub dynamically, with no hard dependency on Phoenix. A custom
implementation just implements this behaviour.
A PubSub is referenced as {module, config} where config is opaque to
ExAgent (e.g. a PubSub server name for Phoenix, or [] for Local/None). The
helper normalize/1 turns the friendly option forms into that tuple.
Summary
Callbacks
Broadcast event to all subscribers of topic.
Subscribe the calling process to topic. Implementations that can't
subscribe (e.g. None) should return {:error, {:subscribe_unsupported, mod}}.
Functions
Broadcast via the resolved {module, config} tuple.
Resolve a PubSub option into a {module, config} tuple.
Subscribe via the resolved tuple.
Callbacks
@callback broadcast(config :: term(), topic :: String.t(), event :: ExAgent.Event.t()) :: :ok | {:error, term()}
Broadcast event to all subscribers of topic.
Subscribe the calling process to topic. Implementations that can't
subscribe (e.g. None) should return {:error, {:subscribe_unsupported, mod}}.
Functions
@spec broadcast({module(), term()}, String.t(), ExAgent.Event.t()) :: :ok | {:error, term()}
Broadcast via the resolved {module, config} tuple.
Resolve a PubSub option into a {module, config} tuple.
Accepts:
nil/:none→{ExAgent.PubSub.None, []}:local→{ExAgent.PubSub.Local, []}module→{module, []}{module, conf}→ as-is
The resolved module must implement this behaviour.
Subscribe via the resolved tuple.