forked from segmentio/kafka-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
saslauthenticate.go
54 lines (43 loc) · 1.16 KB
/
saslauthenticate.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
package kafka
import (
"bufio"
)
type saslAuthenticateRequestV0 struct {
// Data holds the SASL payload
Data []byte
}
func (t saslAuthenticateRequestV0) size() int32 {
return sizeofBytes(t.Data)
}
func (t *saslAuthenticateRequestV0) readFrom(r *bufio.Reader, sz int) (remain int, err error) {
return readBytes(r, sz, &t.Data)
}
func (t saslAuthenticateRequestV0) writeTo(wb *writeBuffer) {
wb.writeBytes(t.Data)
}
type saslAuthenticateResponseV0 struct {
// ErrorCode holds response error code
ErrorCode int16
ErrorMessage string
Data []byte
}
func (t saslAuthenticateResponseV0) size() int32 {
return sizeofInt16(t.ErrorCode) + sizeofString(t.ErrorMessage) + sizeofBytes(t.Data)
}
func (t saslAuthenticateResponseV0) writeTo(wb *writeBuffer) {
wb.writeInt16(t.ErrorCode)
wb.writeString(t.ErrorMessage)
wb.writeBytes(t.Data)
}
func (t *saslAuthenticateResponseV0) readFrom(r *bufio.Reader, sz int) (remain int, err error) {
if remain, err = readInt16(r, sz, &t.ErrorCode); err != nil {
return
}
if remain, err = readString(r, remain, &t.ErrorMessage); err != nil {
return
}
if remain, err = readBytes(r, remain, &t.Data); err != nil {
return
}
return
}