View Source Ash.Notifier.PubSub (ash v2.9.11)

A pubsub notifier extension.

dsl-documentation

DSL Documentation

index

Index

docs

Docs

pub_sub

pub_sub

A section for configuring how resource actions are published over pubsub

See the PubSub and Notifiers guide for more.

Examples:

pub_sub do
  module MyEndpoint
  prefix "post"
  broadcast_type :phoenix_broadcast

  publish :destroy, ["foo", :id]
  publish :update, ["bar", :name] event: "name_change"
  publish_all :create, "created"
end

  • :module (atom/0) - Required. The module to call broadcast/3 on e.g module.broadcast(topic, event, message).

  • :prefix (String.t/0) - A prefix for all pubsub messages, e.g users. A message with created would be published as users:created

  • :broadcast_type - What shape the event payloads will be in. :notification just sends the notification, phoenix_broadcast sends a %Phoenix.Socket.Broadcast{}, and :broadcast sends %{topic: (topic), event: (event), notification: (notification)} The default value is :notification.

  • :name (atom/0) - A named pub sub to pass as the first argument to broadcast.
    If you are using a phoenix Endpoint module for pubsub then this is unnecessary. If you want to use a custom pub sub started with something like {Phoenix.PubSub, name: MyName}, then you can provide MyName to here.

publish

publish

Configure a given action to publish its results over a given topic.

See the PubSub and Notifiers guides for more.

Examples:

publish :create, "created"
publish :assign, "assigned"
  • :action (atom/0) - Required. The name of the action that should be published

  • :topic - Required. The topic to publish

  • :event (String.t/0) - The name of the event to publish. Defaults to the action name

  • :dispatcher (atom/0) - The module to use as a dispatcher. If none is set, the pubsub module provided is used.

publish_all

publish_all

Works just like publish, except that it takes a type and publishes all actions of that type

See the PubSub and Notifiers guides for more.

Examples:

publish_all :create, "created"
  • :type - Publish on all actions of a given type

  • :action (atom/0) - The name of the action that should be published

  • :topic - Required. The topic to publish

  • :event (String.t/0) - The name of the event to publish. Defaults to the action name

  • :dispatcher (atom/0) - The module to use as a dispatcher. If none is set, the pubsub module provided is used.

Link to this section Summary

Link to this section Functions

This function is deprecated. use Ash.Notifier.PubSub.Info.module/1 instead.

See Ash.Notifier.PubSub.Info.module/1.

This function is deprecated. use Ash.Notifier.PubSub.Info.name/1 instead.

See Ash.Notifier.PubSub.Info.name/1.

This function is deprecated. use Ash.Notifier.PubSub.Info.prefix/1 instead.

See Ash.Notifier.PubSub.Info.prefix/1.

This function is deprecated. use Ash.Notifier.PubSub.Info.publications/1 instead.

See Ash.Notifier.PubSub.Info.publications/1.

Link to this function

to_payload(topic, event, notification)

View Source