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

Why AddConcurrentHandlers will panic after connecting to NSQD or NSQ Lookupd? #287

Closed
maplessssy opened this issue Mar 12, 2020 · 2 comments
Labels

Comments

@maplessssy
Copy link

When I read go-nsq source code,I found AddConcurrentHandlers will panic after connecting to NSQD or NSQ Lookupd
Can someone explain why it is so designed?
thx

@ploxiln
Copy link
Member

ploxiln commented Mar 12, 2020

It is just trying to enforce a strict order: add handlers, connect. Connect methods will also fail if no handlers were added first. (That aspect is probably more important, you probably want to ensure a goroutine is already waiting on the unbuffered incomingMessages channel before the conn tries to send on it.)

I guess it panics instead of just returning an error, because a correctly written program will definitely never get this error, so callers may be in the habit of not checking for the error. If starting over again I think we would not do it this way, but there's not a big-enough benefit to changing now.

@ploxiln ploxiln closed this as completed Mar 12, 2020
@maplessssy
Copy link
Author

ok, enforce a strict order is simple and clear. I just think that in some scenarios we may need to dynamically modify the ConcurrentHandlers at runtime to manage consumer concurrent processing power, but maybe there's not a big-enough benefit.

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

No branches or pull requests

2 participants