Comments (4)
I see there's retryDelay
and retryMaxCount
right now. I'm not sure if there's a different design to reconcile that with what I'm proposing.
The sealed trait I mentioned could maybe encode the concept of recoverable errors, unrecoverable errors, and maybe different retry policies (like Schedule.exponential) and so on. If we go with that kind of design, retryDelay
and retryMaxCount
kind of don't make sense anymore (it's too "global" of a setting).
This might require some more thought.
from zio-sqs.
To give a better idea of the alternate design I was thinking of:
sealed trait MessageAction
object MessageAction {
case object Success extends MessageAction
case object Ignore extends MessageAction
case class Delay(delay: Duration) extends MessageAction
case class RecoverableError[E](error: E, retryPolicy: Schedule[Clock, Any, Duration]) extends MessageAction
case class UnrecoverableError[E](error: E) extends MessageAction
}
For the RecoverableError
case you calculate whether to retry or not and for how long based on ZIO Schedule and the ApproximateReceiveCount
header. That means you can do stuff like Schedule.exponential(1.second) && Schedule.recurs(10)
and put it in RecoverableError
to say "retry 10 times using exponential backoff" or anything else you can express with Schedule
.
This design feels more "ZIO" to me than my original proposal.
And maybe you could make retryPolicy
a default param, with Schedule.spaced(settings.retryDelay) && Schedule.recurs(settings.retryMaxCount)
if you want to keep those settings and not make a breaking change.
from zio-sqs.
The retry stuff only exists on the Publisher right now. I understand the need for Delay
as an equivalent to Akka ChangeMessageVisibility
, but for retrying can't you just use the combinators on ZStream
?
from zio-sqs.
Oops, missed the fact that retry was on ProducerSettings
.
As for the relying on retries on ZStream for the consumer, that would work mostly fine in a single consumer case (with the exception of App restarts/crashes... you'll start retrying from 0 again). The issue is mostly with multiple consumers.
If you have multiple consumers in a distributed system pulling entries from the same queue, you can't share a ZIO retry policy between them. This is why I use ApproximateReceiveCount
to drive retries and exponential backoff.
Another case for Delay(0) or Ignore: Let's say I'm doing a rolling deployment with my consumer nodes. They will be running different versions for a while. In this kind of case you may want to say, "I don't know how to handle this version of the message. Let some other consumer pick it up."
By the way, I created a separate issue in ZIO that's kind of a prerequisite for the retries I had in mind:
zio/zio#3468
from zio-sqs.
Related Issues (19)
- Add Readme with instructions, examples, etc
- Add imports to README HOT 1
- Add tests HOT 2
- Setup CI + publish artifacts
- No way to fall back to queue's settings for visibilityTimeout and waitTimeSeconds HOT 2
- Meta data HOT 2
- Parallel consumers from 1 queue HOT 2
- Add 2.13 build/CI HOT 8
- Make the SqsStream infinite HOT 2
- SqsProducer stops working after error from SQS HOT 5
- Issue with message attributes HOT 1
- Release for the latest ZConfig HOT 5
- Default value for visibilityTimeout in SqsStreamSettings should be set to None
- Upgrade to ZIO 2.0 HOT 1
- Missing symbol type for newer zio-aws versions HOT 3
- Update/cross-compile for scala 3 HOT 5
- GenericAwsError when trying to connecting to Sqs HOT 1
- Migrate tests to ZIO Test
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zio-sqs.