saslauthenticate.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package kafka
  2. import (
  3. "bufio"
  4. )
  5. type saslAuthenticateRequestV0 struct {
  6. // Data holds the SASL payload
  7. Data []byte
  8. }
  9. func (t saslAuthenticateRequestV0) size() int32 {
  10. return sizeofBytes(t.Data)
  11. }
  12. func (t *saslAuthenticateRequestV0) readFrom(r *bufio.Reader, sz int) (remain int, err error) {
  13. return readBytes(r, sz, &t.Data)
  14. }
  15. func (t saslAuthenticateRequestV0) writeTo(wb *writeBuffer) {
  16. wb.writeBytes(t.Data)
  17. }
  18. type saslAuthenticateResponseV0 struct {
  19. // ErrorCode holds response error code
  20. ErrorCode int16
  21. ErrorMessage string
  22. Data []byte
  23. }
  24. func (t saslAuthenticateResponseV0) size() int32 {
  25. return sizeofInt16(t.ErrorCode) + sizeofString(t.ErrorMessage) + sizeofBytes(t.Data)
  26. }
  27. func (t saslAuthenticateResponseV0) writeTo(wb *writeBuffer) {
  28. wb.writeInt16(t.ErrorCode)
  29. wb.writeString(t.ErrorMessage)
  30. wb.writeBytes(t.Data)
  31. }
  32. func (t *saslAuthenticateResponseV0) readFrom(r *bufio.Reader, sz int) (remain int, err error) {
  33. if remain, err = readInt16(r, sz, &t.ErrorCode); err != nil {
  34. return
  35. }
  36. if remain, err = readString(r, remain, &t.ErrorMessage); err != nil {
  37. return
  38. }
  39. if remain, err = readBytes(r, remain, &t.Data); err != nil {
  40. return
  41. }
  42. return
  43. }