Skip to content

Commit

Permalink
Add LeaveGroup request and response pair.
Browse files Browse the repository at this point in the history
  • Loading branch information
wvanbergen committed Dec 8, 2015
1 parent b1d40bd commit ccec1aa
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
36 changes: 36 additions & 0 deletions leave_group_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package sarama

type LeaveGroupRequest struct {
GroupId string
MemberId string
}

func (r *LeaveGroupRequest) encode(pe packetEncoder) error {
if err := pe.putString(r.GroupId); err != nil {
return err
}
if err := pe.putString(r.MemberId); err != nil {
return err
}

return nil
}

func (r *LeaveGroupRequest) decode(pd packetDecoder) (err error) {
if r.GroupId, err = pd.getString(); err != nil {
return
}
if r.MemberId, err = pd.getString(); err != nil {
return
}

return nil
}

func (r *LeaveGroupRequest) key() int16 {
return 13
}

func (r *LeaveGroupRequest) version() int16 {
return 0
}
20 changes: 20 additions & 0 deletions leave_group_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package sarama

type LeaveGroupResponse struct {
Err KError
}

func (r *LeaveGroupResponse) encode(pe packetEncoder) error {
pe.putInt16(int16(r.Err))
return nil
}

func (r *LeaveGroupResponse) decode(pd packetDecoder) (err error) {
if kerr, err := pd.getInt16(); err != nil {
return err
} else {
r.Err = KError(kerr)
}

return nil
}

0 comments on commit ccec1aa

Please sign in to comment.