wagslane / go-rabbitmq

A wrapper of streadway/amqp that provides reconnection logic and sane defaults
https://blog.boot.dev/golang/connecting-to-rabbitmq-in-golang-easy/
MIT License
772 stars 126 forks source link

Add backoff duration option #39

Closed 3mb3dw0rk5 closed 2 years ago

3mb3dw0rk5 commented 3 years ago

This adds an option to allow specifying the backoff duration.
Continuously doubling the backoff duration does not seem to be a good service-friendly choice.

I also thought about adding a "callback" function to allow the user to specify a calculation method of the duration but this looks like not needed overhead. What is your impression?

wagslane commented 2 years ago

I do like exponential backoffs for services, ideally with a max, the only problem I have with this is that it doesn't grow overtime. I'd like to hear at least another opinion or two if possible though

wagslane commented 2 years ago

Maybe we allow users to set a "backoff setting" enum, defaults to exponential, but can be set to not change? Then you could set the base time, and the growth setting. I'd approve that if you want to update you PR @3mb3dw0rk5

wagslane commented 2 years ago

@3mb3dw0rk5 Let me know within the next few days if you want to update your PR, if not, I'll go ahead and add the change myself, I like your idea

3mb3dw0rk5 commented 2 years ago

Sorry did not had or have the time atm to look into this. Hope you are fine with implementing this by yourself :+1: