Phoenix PubSub 2.0

Phoenix PubSub is the heart of real-time Phoenix. It powers both Phoenix Channels, via the Phoenix.PubSub module, and Channel Presence, via Phoenix.Tracker. Originally, Phoenix PubSub was written as part of Phoenix, and then extracted as its own project. Since then, many companies have contributed to the project, especially to ensure that its implementation scales to potentially millions of users.

For the upcoming Phoenix PubSub version, the Phoenix team is working mostly on simplifying the implementation, streamlining the code and making custom adapters easier to implement. On the Phoenix side of things, one important change is also coming: Phoenix will no longer start the Phoenix PubSub as part of the endpoint. Instead, you will need to explicitly start Phoenix PubSub in your supervision tree.

In other words, the supervision tree that Phoenix generates in lib/rumbl/application.ex will probably look something like this:

 children = [
 # Start the Ecto repository
  Rumbl.Repo,
 # Start the PubSub system
  {Phoenix.PubSub, ​name:​ Rumbl.PubSub, ​adapter:​ Phoenix.PubSub.PG2},
 # Start the Endpoint when the application starts
  RumblWeb.Endpoint,
 # Starts a Worker by calling: Rumbl.Worker.start_link(arg)
 # {Rumbl.Worker, arg},
 ]

This change is particularly important for umbrella projects, which probably want to start Rumbl.PubSub as part of their non-web applications. (e.g. rumbl), while consuming from Rumbl.PubSub in the web application (e.g. rumbl_web). With this small tweak, you’ll be able to do exactly that.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.254.192