Packages
honeydew
1.2.7
1.5.0
1.4.6
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.0
1.2.8
1.2.7
1.2.6
1.2.5
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.1.6
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
1.0.0-rc7
1.0.0-rc6
1.0.0-rc5
1.0.0-rc4
1.0.0-rc3
1.0.0-rc2
1.0.0-rc1
0.0.11
0.0.10
0.0.9
0.0.8
0.0.7
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1
Pluggable local/clusterable job queue focused on safety.
Current section
Files
Jump to
Current section
Files
lib/honeydew/failure_mode/abandon.ex
defmodule Honeydew.FailureMode.Abandon do
@moduledoc """
Instructs Honeydew to abandon a job on failure.
## Example:
{Honeydew.Queues, [:my_queue, failure_mode: #{inspect __MODULE__}]}
"""
require Logger
alias Honeydew.Job
alias Honeydew.Queue
@behaviour Honeydew.FailureMode
@impl true
def validate_args!([]), do: :ok
def validate_args!(args), do: raise ArgumentError, "You provided arguments (#{inspect args}) to the Abandon failure mode, it only accepts an empty list"
@impl true
def handle_failure(%Job{queue: queue, from: from} = job, reason, []) do
Logger.warn "Job failed because #{inspect reason}, abandoning: #{inspect job}"
# tell the queue that that job can be removed.
queue
|> Honeydew.get_queue
|> Queue.ack(job)
# send the error to the awaiting process, if necessary
with {owner, _ref} <- from,
do: send(owner, %{job | result: {:error, reason}})
end
end