Skip to content

Commit

Permalink
More feedback, renamed structs
Browse files Browse the repository at this point in the history
  • Loading branch information
dim committed Dec 23, 2015
1 parent 914efc5 commit 83f973c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions group_members.go → consumer_group_members.go
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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
}
Expand All @@ -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 {
Expand All @@ -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
}
Expand Down
12 changes: 6 additions & 6 deletions group_members_test.go → consumer_group_members_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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)
Expand All @@ -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},
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion join_group_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions join_group_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion sync_group_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions sync_group_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 83f973c

Please sign in to comment.