Skip to content

Commit

Permalink
fix typos in group structs (segmentio#946)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhansen2 authored Jul 8, 2022
1 parent 556e257 commit 512b856
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions leavegroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func TestClientLeaveGroup(t *testing.T) {
}

for member, assignment := range assignments {
sgRequest.Assigments = append(sgRequest.Assigments, SyncGroupRequestAssignment{
sgRequest.Assignments = append(sgRequest.Assignments, SyncGroupRequestAssignment{
MemberID: member,
Assignment: GroupProtocolAssignment{
AssignedPartitions: assignment,
Expand All @@ -150,8 +150,8 @@ func TestClientLeaveGroup(t *testing.T) {
UserData: []byte(userData),
}

if !reflect.DeepEqual(sgResp.Assigment, expectedAssignment) {
t.Fatalf("\nexpected assignment to be \n%#v \ngot\n%#v", expectedAssignment, sgResp.Assigment)
if !reflect.DeepEqual(sgResp.Assignment, expectedAssignment) {
t.Fatalf("\nexpected assignment to be \n%#v \ngot\n%#v", expectedAssignment, sgResp.Assignment)
}

lgResp, err := client.LeaveGroup(ctx, &LeaveGroupRequest{
Expand Down
20 changes: 10 additions & 10 deletions syncgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type SyncGroupRequest struct {
ProtocolName string

// The group member assignments.
Assigments []SyncGroupRequestAssignment
Assignments []SyncGroupRequestAssignment
}

// SyncGroupRequestAssignment represents an assignement for a goroup memeber.
Expand Down Expand Up @@ -67,7 +67,7 @@ type SyncGroupResponse struct {
ProtocolName string

// The member assignment.
Assigment GroupProtocolAssignment
Assignment GroupProtocolAssignment
}

// GroupProtocolAssignment represents an assignment of topics and partitions for a group memeber.
Expand All @@ -88,17 +88,17 @@ func (c *Client) SyncGroup(ctx context.Context, req *SyncGroupRequest) (*SyncGro
GroupInstanceID: req.GroupInstanceID,
ProtocolType: req.ProtocolType,
ProtocolName: req.ProtocolName,
Assignments: make([]syncgroup.RequestAssignment, 0, len(req.Assigments)),
Assignments: make([]syncgroup.RequestAssignment, 0, len(req.Assignments)),
}

for _, assigment := range req.Assigments {
for _, assignment := range req.Assignments {
assign := consumer.Assignment{
Version: consumer.MaxVersionSupported,
AssignedPartitions: make([]consumer.TopicPartition, 0, len(assigment.Assignment.AssignedPartitions)),
UserData: assigment.Assignment.UserData,
AssignedPartitions: make([]consumer.TopicPartition, 0, len(assignment.Assignment.AssignedPartitions)),
UserData: assignment.Assignment.UserData,
}

for topic, partitions := range assigment.Assignment.AssignedPartitions {
for topic, partitions := range assignment.Assignment.AssignedPartitions {
tp := consumer.TopicPartition{
Topic: topic,
Partitions: make([]int32, 0, len(partitions)),
Expand All @@ -115,7 +115,7 @@ func (c *Client) SyncGroup(ctx context.Context, req *SyncGroupRequest) (*SyncGro
}

syncGroup.Assignments = append(syncGroup.Assignments, syncgroup.RequestAssignment{
MemberID: assigment.MemberID,
MemberID: assignment.MemberID,
Assignment: assignBytes,
})
}
Expand All @@ -138,7 +138,7 @@ func (c *Client) SyncGroup(ctx context.Context, req *SyncGroupRequest) (*SyncGro
Error: makeError(r.ErrorCode, ""),
ProtocolType: r.ProtocolType,
ProtocolName: r.ProtocolName,
Assigment: GroupProtocolAssignment{
Assignment: GroupProtocolAssignment{
AssignedPartitions: make(map[string][]int, len(assignment.AssignedPartitions)),
UserData: assignment.UserData,
},
Expand All @@ -149,7 +149,7 @@ func (c *Client) SyncGroup(ctx context.Context, req *SyncGroupRequest) (*SyncGro
partitions[topicPartition.Topic] = append(partitions[topicPartition.Topic], int(partition))
}
}
res.Assigment.AssignedPartitions = partitions
res.Assignment.AssignedPartitions = partitions

return res, nil
}
Expand Down
6 changes: 3 additions & 3 deletions syncgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func TestClientSyncGroup(t *testing.T) {
}

for member, assignment := range assignments {
sgRequest.Assigments = append(sgRequest.Assigments, SyncGroupRequestAssignment{
sgRequest.Assignments = append(sgRequest.Assignments, SyncGroupRequestAssignment{
MemberID: member,
Assignment: GroupProtocolAssignment{
AssignedPartitions: assignment,
Expand All @@ -151,8 +151,8 @@ func TestClientSyncGroup(t *testing.T) {
UserData: []byte(userData),
}

if !reflect.DeepEqual(sgResp.Assigment, expectedAssignment) {
t.Fatalf("\nexpected assignment to be \n%#v \ngot\n%#v", expectedAssignment, sgResp.Assigment)
if !reflect.DeepEqual(sgResp.Assignment, expectedAssignment) {
t.Fatalf("\nexpected assignment to be \n%#v \ngot\n%#v", expectedAssignment, sgResp.Assignment)
}
}

Expand Down

0 comments on commit 512b856

Please sign in to comment.