Commanded v1.0.0-rc.0 Commanded.PubSub behaviour View Source

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

Link to this section Summary

Functions

Get the configured pub/sub adapter.

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.

Link to this section Types

Link to this type

application()

View Source
application() :: module()

Link to this section Functions

Link to this function

pubsub_provider(application, config)

View Source
pubsub_provider(application(), config :: Keyword.t()) :: module()

Get the configured pub/sub adapter.

Defaults to a local pub/sub, restricted to running on a single node.

Link to this section Callbacks

Link to this callback

broadcast(pubsub, topic, message)

View Source
broadcast(pubsub(), 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(pubsub, config)

View Source
child_spec(pubsub(), config :: Keyword.t()) :: [:supervisor.child_spec()]

Return an optional supervisor spec for pub/sub.

Link to this callback

list(pubsub, topic)

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

List tracked PIDs for a given topic.

Link to this callback

subscribe(pubsub, topic)

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

Subscribes the caller to the PubSub adapter's topic.

Link to this callback

track(pubsub, topic, key)

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

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