|
16 | 16 | from kafka.metrics import AnonMeasurable |
17 | 17 | from kafka.metrics.stats import Avg, Count, Max, Rate |
18 | 18 | from kafka.protocol.find_coordinator import FindCoordinatorRequest |
19 | | -from kafka.protocol.group import HeartbeatRequest, JoinGroupRequest, LeaveGroupRequest, SyncGroupRequest, DEFAULT_GENERATION_ID, UNKNOWN_MEMBER_ID |
| 19 | +from kafka.protocol.group import ( |
| 20 | + HeartbeatRequest, JoinGroupRequest, LeaveGroupRequest, SyncGroupRequest, |
| 21 | + DEFAULT_GENERATION_ID, UNKNOWN_MEMBER_ID, GroupMember, |
| 22 | +) |
20 | 23 | from kafka.util import Timer |
21 | 24 |
|
22 | 25 | log = logging.getLogger('kafka.coordinator') |
@@ -216,10 +219,10 @@ def _perform_assignment(self, leader_id, protocol, members): |
216 | 219 | Arguments: |
217 | 220 | leader_id (str): The id of the leader (which is this member) |
218 | 221 | protocol (str): the chosen group protocol (assignment strategy) |
219 | | - members (list): [(member_id, group_instance_id, metadata_bytes)] from |
220 | | - JoinGroupResponse. metadata_bytes are associated with the chosen |
221 | | - group protocol, and the Coordinator subclass is responsible for |
222 | | - decoding metadata_bytes based on that protocol. |
| 222 | + members (list): [GroupMember] from JoinGroupResponse. |
| 223 | + metadata_bytes are associated with the chosen group protocol, |
| 224 | + and the Coordinator subclass is responsible for decoding |
| 225 | + metadata_bytes based on that protocol. |
223 | 226 |
|
224 | 227 | Returns: |
225 | 228 | dict: {member_id: assignment}; assignment must either be bytes |
@@ -702,9 +705,11 @@ def _on_join_leader(self, response): |
702 | 705 | Future: resolves to member assignment encoded-bytes |
703 | 706 | """ |
704 | 707 | try: |
| 708 | + members = [GroupMember(*member) if response.API_VERSION >= 5 else GroupMember(member[0], None, member[1]) |
| 709 | + for member in response.members] |
705 | 710 | group_assignment = self._perform_assignment(response.leader_id, |
706 | 711 | response.group_protocol, |
707 | | - response.members) |
| 712 | + members) |
708 | 713 | for member_id, assignment in six.iteritems(group_assignment): |
709 | 714 | if not isinstance(assignment, bytes): |
710 | 715 | group_assignment[member_id] = assignment.encode() |
|
0 commit comments