Skip to content

Commit

Permalink
Pass pid in instead of relying on from (oban-bg#843)
Browse files Browse the repository at this point in the history
See current discussion in elixir-ecto/postgrex#643.
  • Loading branch information
josevalim authored and tom-con committed May 1, 2023
1 parent 0afb99b commit a053fb4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/oban/notifiers/postgres.ex
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ defmodule Oban.Notifiers.Postgres do
"""
@spec listen(GenServer.server(), channels :: list(Oban.Notifier.channel())) :: :ok
def listen(server, channels) do
Simple.call(server, {:listen, channels})
Simple.call(server, {:listen, self(), channels})
end

@doc """
Unregister current process from channels
"""
@spec unlisten(GenServer.server(), channels :: list(Oban.Notifier.channel())) :: :ok
def unlisten(server, channels) do
Simple.call(server, {:unlisten, channels})
Simple.call(server, {:unlisten, self(), channels})
end

## Server Callbacks
Expand Down Expand Up @@ -150,7 +150,7 @@ defmodule Oban.Notifiers.Postgres do
{:noreply, state}
end

def handle_call({:listen, channels}, {pid, _} = from, %State{} = state) do
def handle_call({:listen, pid, channels}, from, %State{} = state) do
channels = to_full_channels(state.conf, channels)
new_channels = channels -- Map.keys(state.channels)

Expand All @@ -171,7 +171,7 @@ defmodule Oban.Notifiers.Postgres do
end
end

def handle_call({:unlisten, channels}, {pid, _} = from, %State{} = state) do
def handle_call({:unlisten, pid, channels}, from, %State{} = state) do
channels = to_full_channels(state.conf, channels)

state =
Expand Down

0 comments on commit a053fb4

Please sign in to comment.