ElixirRetry icon indicating copy to clipboard operation
ElixirRetry copied to clipboard

Retry on *any* exception, forever

Open krisleech opened this issue 1 year ago • 0 comments

We are consuming messages from Kafka using Broadway.

Since Broadway will always ack the message we need to handle retry ourselves.

If there is any error we want to retry indefinitely.

This is the code we have:

retry_while with: exponential_backoff(1000) |> cap(10_000) do
  try do
    raise "BOOM"
  rescue
    exception ->
      report(exception, __STACKTRACE__)
      {:cont, nil}
   else
      _ -> {:halt, nil}
  end
end

I assume if I don't use Stream.take then it will retry forever?

Any additional thoughts on this approach?

Thanks!

krisleech avatar Sep 19 '24 09:09 krisleech