Skip to content

Commit

Permalink
Increase timeout to 60s when inserting recipients and delivery jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
wmnnd committed Jul 9, 2024
1 parent 411c52f commit 565fcc9
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/keila/mailings/mailings.ex
Original file line number Diff line number Diff line change
Expand Up @@ -343,13 +343,16 @@ defmodule Keila.Mailings do
@spec deliver_campaign(Campaign.id()) :: {:error, :no_recipients} | {:error, term()} | :ok
def deliver_campaign(id) when is_id(id) do
result =
Repo.transaction(fn ->
case get_and_lock_campaign(id) do
%Campaign{sent_at: sent_at} when not is_nil(sent_at) -> Repo.rollback(:already_sent)
%Campaign{sender_id: nil} -> Repo.rollback(:no_sender)
campaign = %Campaign{} -> do_deliver_campaign(campaign)
end
end)
Repo.transaction(
fn ->
case get_and_lock_campaign(id) do
%Campaign{sent_at: sent_at} when not is_nil(sent_at) -> Repo.rollback(:already_sent)
%Campaign{sender_id: nil} -> Repo.rollback(:no_sender)
campaign = %Campaign{} -> do_deliver_campaign(campaign)
end
end,
timeout: 60_000
)

case result do
{:ok, _n} ->
Expand Down

0 comments on commit 565fcc9

Please sign in to comment.