Skip to content

Commit

Permalink
Add Heartbeat request and response pair.
Browse files Browse the repository at this point in the history
  • Loading branch information
wvanbergen committed Dec 7, 2015
1 parent 821ca5b commit 18a7ed2
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
43 changes: 43 additions & 0 deletions heartbeat_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package sarama

type HeartbeatRequest struct {
GroupId string
GenerationId string
MemberId string
}

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

return nil
}

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

return nil
}

func (r *HeartbeatRequest) key() int16 {
return 12
}

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

type HeartbeatResponse struct {
ErrorCode int16
}

func (r *HeartbeatResponse) encode(pe packetEncoder) error {
pe.putInt16(r.ErrorCode)
return nil
}

func (r *HeartbeatResponse) decode(pd packetDecoder) (err error) {
r.ErrorCode, err = pd.getInt16()
return
}

0 comments on commit 18a7ed2

Please sign in to comment.