Skip to content

Commit

Permalink
Move send after outside if condition
Browse files Browse the repository at this point in the history
  • Loading branch information
zacksiri committed Oct 31, 2024
1 parent 6efeb9a commit 265c707
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/uplink/metrics/producer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,25 @@ defmodule Uplink.Metrics.Producer do

def handle_demand(demand, state) do
Logger.info("[Metrics.Producer] handle demand #{DateTime.utc_now()}")
Process.send_after(self(), :poll, state.poll_interval)

if ready_to_fetch?(state) do
{messages, state} = load_metrics(demand, state)
{:noreply, messages, state}
else
Process.send_after(self(), :poll, state.poll_interval)
{:noreply, [], state}
end
end

@impl true
def handle_info(:poll, state) do
Logger.info("[Metrics.Producer] poll #{DateTime.utc_now()}")
Process.send_after(self(), :poll, state.poll_interval)

if ready_to_fetch?(state) do
{messages, state} = load_metrics(0, state)
{:noreply, messages, state}
else
Process.send_after(self(), :poll, state.poll_interval)
{:noreply, [], state}
end
end
Expand Down

0 comments on commit 265c707

Please sign in to comment.