Scott Baker | 2d89798 | 2019-09-24 11:50:08 -0700 | [diff] [blame] | 1 | package sarama |
| 2 | |
| 3 | type CoordinatorType int8 |
| 4 | |
| 5 | const ( |
Scott Baker | 8487c5d | 2019-10-18 12:49:46 -0700 | [diff] [blame^] | 6 | CoordinatorGroup CoordinatorType = iota |
| 7 | CoordinatorTransaction |
Scott Baker | 2d89798 | 2019-09-24 11:50:08 -0700 | [diff] [blame] | 8 | ) |
| 9 | |
| 10 | type FindCoordinatorRequest struct { |
| 11 | Version int16 |
| 12 | CoordinatorKey string |
| 13 | CoordinatorType CoordinatorType |
| 14 | } |
| 15 | |
| 16 | func (f *FindCoordinatorRequest) encode(pe packetEncoder) error { |
| 17 | if err := pe.putString(f.CoordinatorKey); err != nil { |
| 18 | return err |
| 19 | } |
| 20 | |
| 21 | if f.Version >= 1 { |
| 22 | pe.putInt8(int8(f.CoordinatorType)) |
| 23 | } |
| 24 | |
| 25 | return nil |
| 26 | } |
| 27 | |
| 28 | func (f *FindCoordinatorRequest) decode(pd packetDecoder, version int16) (err error) { |
| 29 | if f.CoordinatorKey, err = pd.getString(); err != nil { |
| 30 | return err |
| 31 | } |
| 32 | |
| 33 | if version >= 1 { |
| 34 | f.Version = version |
| 35 | coordinatorType, err := pd.getInt8() |
| 36 | if err != nil { |
| 37 | return err |
| 38 | } |
| 39 | |
| 40 | f.CoordinatorType = CoordinatorType(coordinatorType) |
| 41 | } |
| 42 | |
| 43 | return nil |
| 44 | } |
| 45 | |
| 46 | func (f *FindCoordinatorRequest) key() int16 { |
| 47 | return 10 |
| 48 | } |
| 49 | |
| 50 | func (f *FindCoordinatorRequest) version() int16 { |
| 51 | return f.Version |
| 52 | } |
| 53 | |
| 54 | func (f *FindCoordinatorRequest) requiredVersion() KafkaVersion { |
| 55 | switch f.Version { |
| 56 | case 1: |
| 57 | return V0_11_0_0 |
| 58 | default: |
| 59 | return V0_8_2_0 |
| 60 | } |
| 61 | } |