-
Notifications
You must be signed in to change notification settings - Fork 85
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
Progressive delay per attempt. #61
Conversation
While discussing #59 I decided to add increasing delay for producer attempts. Something like |
It depends on the algorithm. If it is simple |
I don't think it really needs an algorithm, its just a failure retries not something over complicated. And even in case it needs an algorithm I would prefer to provide a callback function option that will return delay for next attempt. Why would you need to it so strictly configured? I can't imagine these delay to be somehow synchronised with app monitoring or something. |
I think the backoff approach implemented as part of #59 will be sufficient for most people's requirements including ours. I see no reason to require an array of values. |
@oleksiyk if I change this PR from array to a callback |
Frankly, I think this is an over complication. Callback return value should be verified, it should probably be promisified and its errors should somehow be handled. And all this to just calculate the delay? I really hesitate. Can you please explain why you need it to be so controllable and why p.s. |
No, and no. No need value verification. Bluebird does that for us. Promisification is an unnecessary overcomplication too. About So, I'm changing this PR to |
What I mean is that this is not acceptable: return Promise.delay(options.retries.getNextAttemptDelay(attempt)).then... Yes, the program won't crash if callback throws because the callback is called inside the Promise, but you can't verify callback return value here and you can't handle its errors. In order to do so you'll need to either explicitly promisify it or wrap in a
Yes, please! |
Done. Please check @oleksiyk |
I can't merge this.
|
Could you please merge and publish? Ми тут були дуже здивовані першому та другому пунктах, Олексію. |
Guys, its totally my right not to struggle reading through unrelated changes and commits before I decide to merge the PR. As I said in my very first comment, I was going to implement progressive delay myself so I'm not open to spend any more time on the two lines code change. |
This allows progressive delay in
Producer.send()
. For example:The
send()
attempt will happen: immediately, in 1, 2, 5, 10, 30, 60, 60, 60, 60 sec.This is helpful in case kafka becomes unavailable for some reason, but the produces continue to send new messages. In case the kafka was unavailable for couple of seconds only, we'll make sure to send it sooner than later.
Feel free to review. I'll fix anything ASAP.
Thank you @oleksiyk for the amazing full featured module! Great job :)