-
Notifications
You must be signed in to change notification settings - Fork 406
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
Fix #275 and add gochannel concurreny control #295
base: master
Are you sure you want to change the base?
Fix #275 and add gochannel concurreny control #295
Conversation
@@ -342,12 +346,13 @@ func (s *subscriber) Close() { | |||
} | |||
|
|||
func (s *subscriber) sendMessageToSubscriber(msg *message.Message, logFields watermill.LogFields) { | |||
s.sending.Lock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might still need the lock to avoid race conditions with Close
.
defer s.sending.Unlock() | ||
s.sendingChannel <- struct{}{} | ||
defer func() { | ||
<-s.sendingChannel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sendMessageToSubscriber
is also called to deliver persisted messages to newly joining subscribers. I'm not sure if this will behave as expected in this case. Can we have some tests to cover it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll check again and add some tests for it.
Removed the sending lock, and replaced it with a channel to control concurrency.