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

Fix #275 and add gochannel concurreny control #295

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

woostundy
Copy link

Removed the sending lock, and replaced it with a channel to control concurrency.

@woostundy
Copy link
Author

#275

@@ -342,12 +346,13 @@ func (s *subscriber) Close() {
}

func (s *subscriber) sendMessageToSubscriber(msg *message.Message, logFields watermill.LogFields) {
s.sending.Lock()
Copy link
Member

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
Copy link
Member

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?

Copy link
Author

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.

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.

None yet

2 participants