forked from segmentio/kafka-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
heartbeat.go
46 lines (36 loc) · 986 Bytes
/
heartbeat.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package kafka
import "bufio"
type heartbeatRequestV0 struct {
// GroupID holds the unique group identifier
GroupID string
// GenerationID holds the generation of the group.
GenerationID int32
// MemberID assigned by the group coordinator
MemberID string
}
func (t heartbeatRequestV0) size() int32 {
return sizeofString(t.GroupID) +
sizeofInt32(t.GenerationID) +
sizeofString(t.MemberID)
}
func (t heartbeatRequestV0) writeTo(wb *writeBuffer) {
wb.writeString(t.GroupID)
wb.writeInt32(t.GenerationID)
wb.writeString(t.MemberID)
}
type heartbeatResponseV0 struct {
// ErrorCode holds response error code
ErrorCode int16
}
func (t heartbeatResponseV0) size() int32 {
return sizeofInt16(t.ErrorCode)
}
func (t heartbeatResponseV0) writeTo(wb *writeBuffer) {
wb.writeInt16(t.ErrorCode)
}
func (t *heartbeatResponseV0) readFrom(r *bufio.Reader, sz int) (remain int, err error) {
if remain, err = readInt16(r, sz, &t.ErrorCode); err != nil {
return
}
return
}