sasl_handshake_request.go 846 B

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