Skip to content

Commit 63ab9a1

Browse files
committed
refactor: update handle_cast :resume to manage paused state
- Modified the `handle_cast(:resume)` function in multiple modules to check for the `paused` state before resuming polling. - Added a new clause to return the current state without changes if not paused, improving state management and clarity.
1 parent 0088072 commit 63ab9a1

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

lib/algora/integrations/github/poller/comments.ex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,16 @@ defmodule Algora.Github.Poller.Comments do
7070
end
7171

7272
@impl true
73-
def handle_cast(:resume, state) do
73+
def handle_cast(:resume, %{paused: true} = state) do
7474
schedule_poll()
7575
{:noreply, %{state | paused: false}}
7676
end
7777

78+
@impl true
79+
def handle_cast(:resume, state) do
80+
{:noreply, state}
81+
end
82+
7883
@impl true
7984
def handle_call(:get_repo_info, _from, state) do
8085
{:reply, {state.repo_owner, state.repo_name}, state}

lib/algora/integrations/github/poller/events.ex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,16 @@ defmodule Algora.Github.Poller.Events do
7272
end
7373

7474
@impl true
75-
def handle_cast(:resume, state) do
75+
def handle_cast(:resume, %{paused: true} = state) do
7676
schedule_poll()
7777
{:noreply, %{state | paused: false}}
7878
end
7979

80+
@impl true
81+
def handle_cast(:resume, state) do
82+
{:noreply, state}
83+
end
84+
8085
defp schedule_poll do
8186
Process.send_after(self(), :poll, @poll_interval)
8287
end

lib/algora/integrations/github/poller/search.ex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,16 @@ defmodule Algora.Github.Poller.Search do
7070
end
7171

7272
@impl true
73-
def handle_cast(:resume, state) do
73+
def handle_cast(:resume, %{paused: true} = state) do
7474
schedule_poll()
7575
{:noreply, %{state | paused: false}}
7676
end
7777

78+
@impl true
79+
def handle_cast(:resume, state) do
80+
{:noreply, state}
81+
end
82+
7883
@impl true
7984
def handle_call(:get_provider, _from, state) do
8085
{:reply, state.provider, state}

0 commit comments

Comments
 (0)