sasl_authenticate_request.go 1001 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package sarama
  2. type SaslAuthenticateRequest struct {
  3. // Version defines the protocol version to use for encode and decode
  4. Version int16
  5. SaslAuthBytes []byte
  6. }
  7. // APIKeySASLAuth is the API key for the SaslAuthenticate Kafka API
  8. const APIKeySASLAuth = 36
  9. func (r *SaslAuthenticateRequest) encode(pe packetEncoder) error {
  10. return pe.putBytes(r.SaslAuthBytes)
  11. }
  12. func (r *SaslAuthenticateRequest) decode(pd packetDecoder, version int16) (err error) {
  13. r.Version = version
  14. r.SaslAuthBytes, err = pd.getBytes()
  15. return err
  16. }
  17. func (r *SaslAuthenticateRequest) key() int16 {
  18. return APIKeySASLAuth
  19. }
  20. func (r *SaslAuthenticateRequest) version() int16 {
  21. return r.Version
  22. }
  23. func (r *SaslAuthenticateRequest) headerVersion() int16 {
  24. return 1
  25. }
  26. func (r *SaslAuthenticateRequest) isValidVersion() bool {
  27. return r.Version >= 0 && r.Version <= 1
  28. }
  29. func (r *SaslAuthenticateRequest) requiredVersion() KafkaVersion {
  30. switch r.Version {
  31. case 1:
  32. return V2_2_0_0
  33. default:
  34. return V1_0_0_0
  35. }
  36. }