File: saslauthenticate.go

package info (click to toggle)
golang-github-segmentio-kafka-go 0.4.49%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,292 kB
  • sloc: sh: 17; makefile: 10
file content (54 lines) | stat: -rw-r--r-- 1,191 bytes parent folder | download
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
}