init_producer_id_request.go 878 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package sarama
  2. import "time"
  3. type InitProducerIDRequest struct {
  4. TransactionalID *string
  5. TransactionTimeout time.Duration
  6. }
  7. func (i *InitProducerIDRequest) encode(pe packetEncoder) error {
  8. if err := pe.putNullableString(i.TransactionalID); err != nil {
  9. return err
  10. }
  11. pe.putInt32(int32(i.TransactionTimeout / time.Millisecond))
  12. return nil
  13. }
  14. func (i *InitProducerIDRequest) decode(pd packetDecoder, version int16) (err error) {
  15. if i.TransactionalID, err = pd.getNullableString(); err != nil {
  16. return err
  17. }
  18. timeout, err := pd.getInt32()
  19. if err != nil {
  20. return err
  21. }
  22. i.TransactionTimeout = time.Duration(timeout) * time.Millisecond
  23. return nil
  24. }
  25. func (i *InitProducerIDRequest) key() int16 {
  26. return 22
  27. }
  28. func (i *InitProducerIDRequest) version() int16 {
  29. return 0
  30. }
  31. func (i *InitProducerIDRequest) requiredVersion() KafkaVersion {
  32. return V0_11_0_0
  33. }