khenaidoo | ac63710 | 2019-01-14 15:44:34 -0500 | [diff] [blame] | 1 | package sarama |
| 2 | |
Scott Baker | beb3cfa | 2019-10-01 14:44:30 -0700 | [diff] [blame] | 3 | //AddOffsetsToTxnRequest adds offsets to a transaction request |
khenaidoo | ac63710 | 2019-01-14 15:44:34 -0500 | [diff] [blame] | 4 | type AddOffsetsToTxnRequest struct { |
| 5 | TransactionalID string |
| 6 | ProducerID int64 |
| 7 | ProducerEpoch int16 |
| 8 | GroupID string |
| 9 | } |
| 10 | |
| 11 | func (a *AddOffsetsToTxnRequest) encode(pe packetEncoder) error { |
| 12 | if err := pe.putString(a.TransactionalID); err != nil { |
| 13 | return err |
| 14 | } |
| 15 | |
| 16 | pe.putInt64(a.ProducerID) |
| 17 | |
| 18 | pe.putInt16(a.ProducerEpoch) |
| 19 | |
| 20 | if err := pe.putString(a.GroupID); err != nil { |
| 21 | return err |
| 22 | } |
| 23 | |
| 24 | return nil |
| 25 | } |
| 26 | |
| 27 | func (a *AddOffsetsToTxnRequest) decode(pd packetDecoder, version int16) (err error) { |
| 28 | if a.TransactionalID, err = pd.getString(); err != nil { |
| 29 | return err |
| 30 | } |
| 31 | if a.ProducerID, err = pd.getInt64(); err != nil { |
| 32 | return err |
| 33 | } |
| 34 | if a.ProducerEpoch, err = pd.getInt16(); err != nil { |
| 35 | return err |
| 36 | } |
| 37 | if a.GroupID, err = pd.getString(); err != nil { |
| 38 | return err |
| 39 | } |
| 40 | return nil |
| 41 | } |
| 42 | |
| 43 | func (a *AddOffsetsToTxnRequest) key() int16 { |
| 44 | return 25 |
| 45 | } |
| 46 | |
| 47 | func (a *AddOffsetsToTxnRequest) version() int16 { |
| 48 | return 0 |
| 49 | } |
| 50 | |
| 51 | func (a *AddOffsetsToTxnRequest) requiredVersion() KafkaVersion { |
| 52 | return V0_11_0_0 |
| 53 | } |