Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Pass Error to retryable? #12

Open
erikreedstrom opened this issue Apr 26, 2019 · 1 comment
Open

[RFC] Pass Error to retryable? #12

erikreedstrom opened this issue Apr 26, 2019 · 1 comment

Comments

@erikreedstrom
Copy link

There are times when an error may dictate a retry; i.e. network error. However, there are times when the failure indicates any subsequent job will fail. For instance, a ConstraintError from Ecto.

By passing the error into retry function, we can inspect and handle accordingly.

defp handle_error(job, {type, exception}, before_run_state, state, stacktrace) do
  cb = with true <- Job.retryable?(job, {type, exception}),
    {:ok, :buried} <- Retry.retry(state.channel, state.partition_id, job)
  do
    :on_buried
  else
    _ -> :on_error
  end

  job_done(job, :ack, state)
  callback(cb, [state.partition_id, job, {type, exception}, stacktrace, before_run_state])
end
def retryable?(%__MODULE__{} = job, error) do
  if function_exported?(job.module, :retryable?, 1) do
    job.module.retryable?(error)
  else
    false
  end
end
@nulian
Copy link
Contributor

nulian commented May 1, 2019

We will take these 2 issues in mind this month we gonna do a fair amount of improvements on problems we are noticing with our system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants