View Source EchoPubSub

Build Status hex.pm version hex.pm license

A Phoenix.PubSub adapter that distributes messages between nodes using the erlang :pg module, like the default adapter, however with the additional guarentees of "at least once" delivery.

This means that you can have nodes dissconnect temporarily from the cluster, and then "catch up" when they rejoin by maintaining a buffer of messages, and read cursors.

See the Docs for more information.

Usage

def deps do
  [
    {:echo_pubsub, "~> 0.1.0"}
  ]
end

# application.ex
children = [
  # ...,
  {Phoenix.PubSub, name: MyApp.PubSub, adapter: EchoPubSub}
]

Config Options

OptionDescriptionDefault
:-----------------------:------------------------------------------------------------------------:-------------
:nameThe required name to register the PubSub processes, ie: MyApp.PubSub
:pool_sizeDetermines the number of workers and producers on each node1
:buffer_sizeThe numbers of messages to hold in memory for each producer in the pool10_000

Subscribing processes should handle the message {:cursor_expired, node_name} which indicates that your client has been disconnected long enough that your position in the broadcaster's buffer has been overwritten. At this point it is the subscribing process's job to return to a valid state i.e. reloading state from source like database or another node.