From 1f6fbeb27e7d281c549e62471e8cfa614d288322 Mon Sep 17 00:00:00 2001 From: Max Strother Date: Fri, 30 Aug 2024 22:15:58 +0200 Subject: [PATCH] fix: DispatchWorker missing a 2-element stop clause in handle_info (#261) --- CHANGELOG.md | 1 + lib/pigeon/adapter.ex | 11 ++++++----- lib/pigeon/dispatcher_worker.ex | 3 +++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06ad3beb..a39bdf9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ **Changed** - Bump `goth` dependency to `~> 1.4.3`. ([#252](https://github.com/codedge-llc/pigeon/pull/252)) +- Fix `DispatcherWorker` missing a clause for `{:stop, reason}` in the handle_info function. ## v2.0.0-rc.2 diff --git a/lib/pigeon/adapter.ex b/lib/pigeon/adapter.ex index b54b574a..20c53a56 100644 --- a/lib/pigeon/adapter.ex +++ b/lib/pigeon/adapter.ex @@ -45,15 +45,16 @@ defmodule Pigeon.Adapter do """ @callback init(opts :: Keyword.t()) :: {:ok, any} | {:stop, any} - @doc """ - Invoked to handle all other messages. - """ - @callback handle_info(term, term) :: {:noreply, term} - @doc """ Invoked to handle push notifications. """ @callback handle_push(notification :: struct | [struct], state :: term) :: {:noreply, new_state :: term} | {:stop, reason :: term, new_state :: term} + + @doc """ + Invoked to handle all other messages. + """ + @callback handle_info(term, term) :: + {:noreply, term} | {:stop, reason :: term} end diff --git a/lib/pigeon/dispatcher_worker.ex b/lib/pigeon/dispatcher_worker.ex index 935d0c87..9aa5c791 100644 --- a/lib/pigeon/dispatcher_worker.ex +++ b/lib/pigeon/dispatcher_worker.ex @@ -39,6 +39,9 @@ defmodule Pigeon.DispatcherWorker do {:noreply, new_state} -> {:noreply, %{adapter: adapter, state: new_state}} + {:stop, reason} -> + {:stop, reason, %{adapter: adapter, state: state}} + {:stop, reason, new_state} -> {:stop, reason, %{adapter: adapter, state: new_state}} end