sasl_handshake_response.go 984 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package sarama
  2. type SaslHandshakeResponse struct {
  3. Version int16
  4. Err KError
  5. EnabledMechanisms []string
  6. }
  7. func (r *SaslHandshakeResponse) encode(pe packetEncoder) error {
  8. pe.putInt16(int16(r.Err))
  9. return pe.putStringArray(r.EnabledMechanisms)
  10. }
  11. func (r *SaslHandshakeResponse) decode(pd packetDecoder, version int16) error {
  12. kerr, err := pd.getInt16()
  13. if err != nil {
  14. return err
  15. }
  16. r.Err = KError(kerr)
  17. if r.EnabledMechanisms, err = pd.getStringArray(); err != nil {
  18. return err
  19. }
  20. return nil
  21. }
  22. func (r *SaslHandshakeResponse) key() int16 {
  23. return 17
  24. }
  25. func (r *SaslHandshakeResponse) version() int16 {
  26. return r.Version
  27. }
  28. func (r *SaslHandshakeResponse) headerVersion() int16 {
  29. return 0
  30. }
  31. func (r *SaslHandshakeResponse) isValidVersion() bool {
  32. return r.Version >= 0 && r.Version <= 1
  33. }
  34. func (r *SaslHandshakeResponse) requiredVersion() KafkaVersion {
  35. switch r.Version {
  36. case 1:
  37. return V1_0_0_0
  38. default:
  39. return V0_10_0_0
  40. }
  41. }