-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Introduce ConsumerGroups #1083
Introduce ConsumerGroups #1083
Conversation
Perhaps I'm missing a use case, but why distinguish |
Also feel free to split the |
The consumer group joins a cluster and acquires a semi-permanent member ID on its first session. A session on the other hand lives until the next rebalance cycle. Once Done() triggers, the user must stop consuming the claimed partitions, commit offsets, Close() the session and restart it to rejoin the cluster under the same member ID. One way or another, the consumer group life cycle requires a big Thoughts? |
So actually, I can see no better way. The consumer group is effectively an iterator over sessions. Obviously, I could move the topics argument to NewConsumerGroup, but I have been frequently asked for a new feature on sarama-cluster to allow users to change the topic subscriptions without restarting the (cluster) consumer, that's why I have decided to put it on the session initialiser. |
Are there actually benefits to doing this in terms of connection/metadata setup or whatever? reads... Oh, the memberID is persisted in the Group itself. I didn't realize that the Group carried any state between sessions. That makes sense. Wait, is it even possible to change the topic subscriptions broker-side without introducing a whole new group ID? How can the broker coordinate if the different group members subscribe to different topics entirely?
In your sample this is called
So I suppose the issue with something like I wonder if it makes sense to have And then I'm not sure if these ideas actually end up making sense in practical usage, but I think they would make your sample sarama-cluster implementation a little simpler and more robust. edit: I guess error-handling becomes annoying then doesn't it |
consumer_group.go
Outdated
} | ||
|
||
func (s *consumerGroupSession) Claims() map[string][]int32 { return s.claims } | ||
func (s *consumerGroupSession) MemberID() string { return s.parent.memberID } |
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.
should this just be exposed on the ConsumerGroup itself?
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.
It's not really helpful as these are only available for the duration of the session. A session can be terminated by the server (failing heartbeat) or by the client (heartbeat is stopped)
One idea is to make Subscribe this the previous session, if one exists. It would make things more fluid but also less obvious. I thought about exposing the iterator via a Sessions() channel before, but yes, error handling would be quite annoying. |
... make Subscribe close/release... |
}, | ||
}, | ||
{ | ||
members: map[string][]string{"M1": {"T1"}, "M2": {"T1", "T2"}}, |
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.
How can the broker coordinate if the different group members subscribe to different topics entirely?
Here's an example of that. Topics can be distributed unevenly even under the same group ID.
} | ||
wg.Wait() | ||
}() | ||
if err != nil { |
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.
TODO: remove this
@eapache I have created a high-level consumer (which would be sarama-cluster v3) on top of this patch - bsm/sarama-cluster#234. What do you think?
|
NewConsumerGroupFromClient |
Closing in favour of #1099 |
Hi,
I've been trying to extract some of the lessons from https://github.com/bsm/sarama-cluster into a general purpose, low-level consumer group and would like to get some feedback on the approach.
An implementation of sarama-cluster with the proposed API would look something like this:
What do you think?