From 83f973c2d6d898c349c3eecfa65fd0e38b24e172 Mon Sep 17 00:00:00 2001 From: Dimitrij Denissenko Date: Wed, 23 Dec 2015 22:11:41 +0000 Subject: [PATCH] More feedback, renamed structs --- group_members.go => consumer_group_members.go | 12 ++++++------ ...members_test.go => consumer_group_members_test.go | 12 ++++++------ join_group_request.go | 2 +- join_group_response.go | 6 +++--- sync_group_request.go | 2 +- sync_group_response.go | 4 ++-- 6 files changed, 19 insertions(+), 19 deletions(-) rename group_members.go => consumer_group_members.go (77%) rename group_members_test.go => consumer_group_members_test.go (87%) diff --git a/group_members.go b/consumer_group_members.go similarity index 77% rename from group_members.go rename to consumer_group_members.go index bdf0e7343..9d92d350a 100644 --- a/group_members.go +++ b/consumer_group_members.go @@ -1,12 +1,12 @@ package sarama -type GroupMemberMetadata struct { +type ConsumerGroupMemberMetadata struct { Version int16 Topics []string UserData []byte } -func (m *GroupMemberMetadata) encode(pe packetEncoder) error { +func (m *ConsumerGroupMemberMetadata) encode(pe packetEncoder) error { pe.putInt16(m.Version) if err := pe.putStringArray(m.Topics); err != nil { @@ -20,7 +20,7 @@ func (m *GroupMemberMetadata) encode(pe packetEncoder) error { return nil } -func (m *GroupMemberMetadata) decode(pd packetDecoder) (err error) { +func (m *ConsumerGroupMemberMetadata) decode(pd packetDecoder) (err error) { if m.Version, err = pd.getInt16(); err != nil { return } @@ -36,13 +36,13 @@ func (m *GroupMemberMetadata) decode(pd packetDecoder) (err error) { return nil } -type GroupMemberAssignment struct { +type ConsumerGroupMemberAssignment struct { Version int16 Topics map[string][]int32 UserData []byte } -func (m *GroupMemberAssignment) encode(pe packetEncoder) error { +func (m *ConsumerGroupMemberAssignment) encode(pe packetEncoder) error { pe.putInt16(m.Version) if err := pe.putArrayLength(len(m.Topics)); err != nil { @@ -65,7 +65,7 @@ func (m *GroupMemberAssignment) encode(pe packetEncoder) error { return nil } -func (m *GroupMemberAssignment) decode(pd packetDecoder) (err error) { +func (m *ConsumerGroupMemberAssignment) decode(pd packetDecoder) (err error) { if m.Version, err = pd.getInt16(); err != nil { return } diff --git a/group_members_test.go b/consumer_group_members_test.go similarity index 87% rename from group_members_test.go rename to consumer_group_members_test.go index 599502e0d..4213d81ee 100644 --- a/group_members_test.go +++ b/consumer_group_members_test.go @@ -27,8 +27,8 @@ var ( } ) -func TestGroupMemberMetadata(t *testing.T) { - meta := &GroupMemberMetadata{ +func TestConsumerGroupMemberMetadata(t *testing.T) { + meta := &ConsumerGroupMemberMetadata{ Version: 1, Topics: []string{"one", "two"}, UserData: []byte{0x01, 0x02, 0x03}, @@ -41,7 +41,7 @@ func TestGroupMemberMetadata(t *testing.T) { t.Errorf("Encoded data does not match expectation\nexpected: %v\nactual: %v", groupMemberMetadata, buf) } - meta2 := new(GroupMemberMetadata) + meta2 := new(ConsumerGroupMemberMetadata) err = decode(buf, meta2) if err != nil { t.Error("Failed to decode data", err) @@ -50,8 +50,8 @@ func TestGroupMemberMetadata(t *testing.T) { } } -func TestGroupMemberAssignment(t *testing.T) { - amt := &GroupMemberAssignment{ +func TestConsumerGroupMemberAssignment(t *testing.T) { + amt := &ConsumerGroupMemberAssignment{ Version: 1, Topics: map[string][]int32{ "one": []int32{0, 2, 4}, @@ -67,7 +67,7 @@ func TestGroupMemberAssignment(t *testing.T) { t.Errorf("Encoded data does not match expectation\nexpected: %v\nactual: %v", groupMemberAssignment, buf) } - amt2 := new(GroupMemberAssignment) + amt2 := new(ConsumerGroupMemberAssignment) err = decode(buf, amt2) if err != nil { t.Error("Failed to decode data", err) diff --git a/join_group_request.go b/join_group_request.go index 13812449e..5884d79d4 100644 --- a/join_group_request.go +++ b/join_group_request.go @@ -93,7 +93,7 @@ func (r *JoinGroupRequest) AddGroupProtocol(name string, metadata []byte) { r.GroupProtocols[name] = metadata } -func (r *JoinGroupRequest) AddGroupProtocolMetadata(name string, metadata *GroupMemberMetadata) error { +func (r *JoinGroupRequest) AddGroupProtocolMetadata(name string, metadata *ConsumerGroupMemberMetadata) error { bin, err := encode(metadata) if err != nil { return err diff --git a/join_group_response.go b/join_group_response.go index 15e16cf1c..16f6b9b40 100644 --- a/join_group_response.go +++ b/join_group_response.go @@ -9,10 +9,10 @@ type JoinGroupResponse struct { Members map[string][]byte } -func (r *JoinGroupResponse) GetMembers() (map[string]GroupMemberMetadata, error) { - members := make(map[string]GroupMemberMetadata, len(r.Members)) +func (r *JoinGroupResponse) GetMembers() (map[string]ConsumerGroupMemberMetadata, error) { + members := make(map[string]ConsumerGroupMemberMetadata, len(r.Members)) for id, bin := range r.Members { - meta := new(GroupMemberMetadata) + meta := new(ConsumerGroupMemberMetadata) if err := decode(bin, meta); err != nil { return nil, err } diff --git a/sync_group_request.go b/sync_group_request.go index b0faed2ef..031cf0f2f 100644 --- a/sync_group_request.go +++ b/sync_group_request.go @@ -85,7 +85,7 @@ func (r *SyncGroupRequest) AddGroupAssignment(memberId string, memberAssignment r.GroupAssignments[memberId] = memberAssignment } -func (r *SyncGroupRequest) AddGroupAssignmentMember(memberId string, memberAssignment *GroupMemberAssignment) error { +func (r *SyncGroupRequest) AddGroupAssignmentMember(memberId string, memberAssignment *ConsumerGroupMemberAssignment) error { bin, err := encode(memberAssignment) if err != nil { return err diff --git a/sync_group_response.go b/sync_group_response.go index 406c27db5..49c86922d 100644 --- a/sync_group_response.go +++ b/sync_group_response.go @@ -5,8 +5,8 @@ type SyncGroupResponse struct { MemberAssignment []byte } -func (r *SyncGroupResponse) GetMemberAssignment() (*GroupMemberAssignment, error) { - assignment := new(GroupMemberAssignment) +func (r *SyncGroupResponse) GetMemberAssignment() (*ConsumerGroupMemberAssignment, error) { + assignment := new(ConsumerGroupMemberAssignment) err := decode(r.MemberAssignment, assignment) return assignment, err }