Scott Baker | 2d89798 | 2019-09-24 11:50:08 -0700 | [diff] [blame] | 1 | package sarama |
| 2 | |
| 3 | import ( |
| 4 | "time" |
| 5 | ) |
| 6 | |
Scott Baker | 8487c5d | 2019-10-18 12:49:46 -0700 | [diff] [blame^] | 7 | //AddOffsetsToTxnResponse is a response type for adding offsets to txns |
Scott Baker | 2d89798 | 2019-09-24 11:50:08 -0700 | [diff] [blame] | 8 | type AddOffsetsToTxnResponse struct { |
| 9 | ThrottleTime time.Duration |
| 10 | Err KError |
| 11 | } |
| 12 | |
| 13 | func (a *AddOffsetsToTxnResponse) encode(pe packetEncoder) error { |
| 14 | pe.putInt32(int32(a.ThrottleTime / time.Millisecond)) |
| 15 | pe.putInt16(int16(a.Err)) |
| 16 | return nil |
| 17 | } |
| 18 | |
| 19 | func (a *AddOffsetsToTxnResponse) decode(pd packetDecoder, version int16) (err error) { |
| 20 | throttleTime, err := pd.getInt32() |
| 21 | if err != nil { |
| 22 | return err |
| 23 | } |
| 24 | a.ThrottleTime = time.Duration(throttleTime) * time.Millisecond |
| 25 | |
| 26 | kerr, err := pd.getInt16() |
| 27 | if err != nil { |
| 28 | return err |
| 29 | } |
| 30 | a.Err = KError(kerr) |
| 31 | |
| 32 | return nil |
| 33 | } |
| 34 | |
| 35 | func (a *AddOffsetsToTxnResponse) key() int16 { |
| 36 | return 25 |
| 37 | } |
| 38 | |
| 39 | func (a *AddOffsetsToTxnResponse) version() int16 { |
| 40 | return 0 |
| 41 | } |
| 42 | |
| 43 | func (a *AddOffsetsToTxnResponse) requiredVersion() KafkaVersion { |
| 44 | return V0_11_0_0 |
| 45 | } |