View Source Commanded.PubSub.Adapter behaviour (Commanded v1.4.6)

Pub/sub behaviour for use by Commanded to subscribe to and broadcast messages.

Summary

Callbacks

Broadcasts message on given topic.

Return an optional supervisor spec for pub/sub.

List tracked PIDs for a given topic.

Subscribes the caller to the PubSub adapter's topic.

Track the current process under the given topic, uniquely identified by key.

Types

@type adapter_meta() :: map()
@type application() :: Commanded.Application.t()

Callbacks

Link to this callback

broadcast(adapter_meta, topic, message)

View Source
@callback broadcast(adapter_meta(), topic :: String.t(), message :: term()) ::
  :ok | {:error, term()}

Broadcasts message on given topic.

  • topic - The topic to broadcast to, ie: "users:123"
  • message - The payload of the broadcast
Link to this callback

child_spec(application, config)

View Source
@callback child_spec(application(), config :: Keyword.t()) ::
  {:ok, [:supervisor.child_spec() | {module(), term()} | module()],
   adapter_meta()}

Return an optional supervisor spec for pub/sub.

Link to this callback

list(adapter_meta, topic)

View Source
@callback list(adapter_meta(), topic :: String.t()) :: [{term(), pid()}]

List tracked PIDs for a given topic.

Link to this callback

subscribe(adapter_meta, topic)

View Source
@callback subscribe(adapter_meta(), topic :: String.t()) :: :ok | {:error, term()}

Subscribes the caller to the PubSub adapter's topic.

Link to this callback

track(adapter_meta, topic, key)

View Source
@callback track(adapter_meta(), topic :: String.t(), key :: term()) ::
  :ok | {:error, term()}

Track the current process under the given topic, uniquely identified by key.