-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Heartbeat request and response pair.
- Loading branch information
1 parent
821ca5b
commit 18a7ed2
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |