diff --git a/README.md b/README.md index a8b098b..68fb102 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/eredis_sub.ex b/lib/eredis_sub.ex index 9620063..ef274f9 100644 --- a/lib/eredis_sub.ex +++ b/lib/eredis_sub.ex @@ -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 @@ -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 diff --git a/lib/eredis_sub/handler.ex b/lib/eredis_sub/handler.ex index f9c153e..6b0450a 100644 --- a/lib/eredis_sub/handler.ex +++ b/lib/eredis_sub/handler.ex @@ -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 diff --git a/lib/eredis_sub/server.ex b/lib/eredis_sub/server.ex index 1cbbef2..31e89a5 100644 --- a/lib/eredis_sub/server.ex +++ b/lib/eredis_sub/server.ex @@ -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 = diff --git a/test/eredis_sub_test.exs b/test/eredis_sub_test.exs index 0b504ab..1515ef5 100644 --- a/test/eredis_sub_test.exs +++ b/test/eredis_sub_test.exs @@ -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