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 listen error functionality to listen async error from rabbus #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alileza
Copy link
Contributor

@alileza alileza commented Sep 18, 2018

in case of failed to reconnect, or some internal error on rabbus that happens asyncronously

@@ -432,6 +434,7 @@ func (r *Rabbus) handleAmqpClose(err error) {
time.Sleep(time.Second)
aw, err := amqpwrap.New(r.config.dsn, r.config.passiveex)
if err != nil {
r.listenErrChan <- err
Copy link
Collaborator

@puellanivis puellanivis Dec 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each of these sends, needs to use the non-blocking version:

select {
case r.listenErrChan <- err:
default:
}

Or else the first send that exceeds the buffer size will block forever, if no one is listening. This also means you can remove the buffer on the listenErrChan, but maybe it is nice to have a buffer like time.Timer has so that if the listener is busy when a second error is sent, it will not get dropped on the floor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants