forked from segmentio/kafka-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
heartbeat.go
56 lines (45 loc) · 1.3 KB
/
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
47
48
49
50
51
52
53
54
55
56
package kafka
import "bufio"
type heartbeatRequestV1 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 heartbeatRequestV1) size() int32 {
return sizeofString(t.GroupID) +
sizeofInt32(t.GenerationID) +
sizeofString(t.MemberID)
}
func (t heartbeatRequestV1) writeTo(w *bufio.Writer) {
writeString(w, t.GroupID)
writeInt32(w, t.GenerationID)
writeString(w, t.MemberID)
}
type heartbeatResponseV1 struct {
// ThrottleTimeMS holds the duration in milliseconds for which the request
// was throttled due to quota violation (Zero if the request did not violate
// any quota)
ThrottleTimeMS int32
// ErrorCode holds response error code
ErrorCode int16
}
func (t heartbeatResponseV1) size() int32 {
return sizeofInt32(t.ThrottleTimeMS) +
sizeofInt16(t.ErrorCode)
}
func (t heartbeatResponseV1) writeTo(w *bufio.Writer) {
writeInt32(w, t.ThrottleTimeMS)
writeInt16(w, t.ErrorCode)
}
func (t *heartbeatResponseV1) readFrom(r *bufio.Reader, sz int) (remain int, err error) {
if remain, err = readInt32(r, sz, &t.ThrottleTimeMS); err != nil {
return
}
if remain, err = readInt16(r, remain, &t.ErrorCode); err != nil {
return
}
return
}