Condukt.Notifiers.PubSub (Condukt v3.0.0)

Copy Markdown View Source

Publishes session events over Phoenix.PubSub.

This is how one session reaches many viewers, including viewers connected to other nodes: the session broadcasts once and PubSub delivers to everyone subscribed to its topic, wherever they are.

Condukt.run(MyApp.Agent, "hello",
  notifier: {Condukt.Notifiers.PubSub, server: MyApp.PubSub}
)

Subscribers listen on the session's topic and receive {:condukt_event, session_id, event}:

Phoenix.PubSub.subscribe(MyApp.PubSub, Condukt.Notifiers.PubSub.topic(session_id))

Numbered view changes go to a topic of their own, so subscribers of the event topic receive nothing new. They arrive as {:condukt_change, session_id, epoch, seq, change}, the same message Condukt.Session.watch/1 sends locally. Subscribe first, then fetch the view, and apply each change with Condukt.Session.View.advance/4:

Phoenix.PubSub.subscribe(MyApp.PubSub, Condukt.Notifiers.PubSub.changes_topic(session_id))
view = Condukt.Session.view(session)

Options

  • :server - the PubSub server name (required)
  • :prefix - topic prefix, "condukt:session:" by default

Requires :phoenix_pubsub, which Condukt declares as optional so projects that fan out some other way do not carry it.

Summary

Functions

The topic a session publishes its numbered view changes on.

The topic a session publishes on.

Functions

changes_topic(session_id, prefix \\ "condukt:session:")

The topic a session publishes its numbered view changes on.

topic(session_id, prefix \\ "condukt:session:")

The topic a session publishes on.