init_producer_id_request.go 947 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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) headerVersion() int16 {
  32. return 1
  33. }
  34. func (i *InitProducerIDRequest) requiredVersion() KafkaVersion {
  35. return V0_11_0_0
  36. }