Skip to content

Commit

Permalink
Rename handle function to handle_pubsub_message
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandremcosta committed Jun 12, 2024
1 parent 8741d7f commit 454124e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defmodule MyModule do
@behaviour EredisSub.Handler

@impl EredisSub.Handler
def handle(message, metadata) do
def handle_pubsub_message(message, metadata) do
# Do something...
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/eredis_sub.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defmodule EredisSub do
@behaviour EredisSub.Handler
@impl EredisSub.Handler
def handle(message, metadata) do
def handle_pubsub_message(message, metadata) do
# Do something...
end
end
Expand Down Expand Up @@ -63,7 +63,7 @@ defmodule EredisSub do
...> metadata = %{}
...>
...> defmodule FooBar do
...> def handle("foo", _metadata) do
...> def handle_pubsub_message(_message, _metadata) do
...> # Do something...
...> end
...> end
Expand Down
2 changes: 1 addition & 1 deletion lib/eredis_sub/handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ defmodule EredisSub.Handler do
Receives a binary message and a metadata that can be customized upon subscription.
Return value is ignored.
"""
@callback handle(message :: binary, metadata :: term) :: term
@callback handle_pubsub_message(message :: binary, metadata :: term) :: term
end
2 changes: 1 addition & 1 deletion lib/eredis_sub/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ defmodule EredisSub.Server do
defp apply_no_link(channel, handler_module, message, metadata) do
Task.start(fn ->
try do
handler_module.handle(message, metadata)
handler_module.handle_pubsub_message(message, metadata)
rescue
e ->
error =
Expand Down
2 changes: 1 addition & 1 deletion test/eredis_sub_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defmodule EredisSubTest do
end

defmodule PingPong do
def handle("ping", metadata) do
def handle_pubsub_message("ping", metadata) do
test_pid = Map.fetch!(metadata, :test_pid)
send(test_pid, :pong)
end
Expand Down

0 comments on commit 454124e

Please sign in to comment.