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

Add error handling mechanism to higher-level processing methods. #14

Open
satabin opened this issue Apr 5, 2024 · 0 comments
Open

Add error handling mechanism to higher-level processing methods. #14

satabin opened this issue Apr 5, 2024 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@satabin
Copy link
Collaborator

satabin commented Apr 5, 2024

Idea from #13 (comment)

Currently the process methods fail and nack upon any exception raised in the processing.
The idea is to give users a way to make decisions upon failures. This can be used to implement exponential backoff, dead-lettering of malformed messages, etc...

The basic abstraction could look like:

// this is a SAM, so any function Throwable => F[Decision] will do
// the `F` allows for logging or any other effectful action suited for the handler
trait ErrorHandler[F[_]] {
  def handle(msg: RawMessage, t: Throwable): F[Decision]
}

sealed trait Decision
object Decision {
  case object Drop extends Decision
  case class Fail(t: Throwable, ack: Boolean) extends Decision
  case object DeadLetter extends Decision
  case class Reenqueue(delay: Option[FiniteDuration]) extends Decision
}

We can provide a sensible default handler (nacking on any error except for deserialization errors for instance).

@satabin satabin added the enhancement New feature or request label May 6, 2024
@satabin satabin added this to the 0.2.0 milestone May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant