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

Close consumer message channel when consumer closed. #387

Open
cocotyty opened this issue Nov 10, 2020 · 3 comments · May be fixed by #808
Open

Close consumer message channel when consumer closed. #387

cocotyty opened this issue Nov 10, 2020 · 3 comments · May be fixed by #808

Comments

@cocotyty
Copy link

cocotyty commented Nov 10, 2020

Is your feature request related to a problem? Please describe.

lots of consumer code maybe like this:

for msg := range consumer.Chan(){
   // consume msg
}

if not close channel when consumer close, maybe cause goroutine leak.

Describe the solution you'd like

when close a consumer,close the consumer's message channel.

Describe alternatives you've considered

Additional context

@gonejack
Copy link

Hello, is this a bug or expected behaviour?

@omnilight
Copy link
Contributor

Hello, I've also interested in this issue.

Currently it is impossible to detect if consumer closed if you are not using consumer.Receive() method. But this method is blocking and is intended to be used as a receiver of the message.

Maybe we can either add method like Closed() to the interface, or change Receive() method as proposed by issue author?

@isalb729
Copy link

Just met the same issue. This method would be more useful if you can close the channel.

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

Successfully merging a pull request may close this issue.

5 participants