siu

siu

Phoenix PubSub does not use custom dispatcher

I need a custom dispatcher for Phoenix PubSub in my application, but when I broadcast a message in some channel, Phoenix does not use my custom dispatcher for message delivery.
my dispatcher:

defmodule AuthGuardian.MessageDispatcher do
  def dispatch(subscribers, _from, msg) do
    # some logic
    Enum.each(subscribers, fn {pid, _} -> send(pid, msg) end)
  end
end

config.exs :

config :auth_guardian, AuthGuardian.PubSub,
  dispatcher: AuthGuardian.PoshtiDispatcher

application.ex :

def start(_type, _args) do
    children = [
      # Start the PubSub system
      {Phoenix.PubSub, name: AuthGuardian.PubSub, dispatcher: AuthGuardian.MessageDispatcher}
      ...
    ]

    opts = [strategy: :one_for_one, name: AuthGuardian.Supervisor]
    Supervisor.start_link(children, opts)
  end

I know we can use Phoenix.PubSub.broadcast() and pass our custom dispatcher directly to the broadcast but we need broadcast() function in our channel module works with the custom dispatcher.

Where Next?

Popular in Questions Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36820 110
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement