blob: 0ab5cb5ff575cc8bd2b97b2bad5f19e30bdb06c5 [file] [log] [blame]
William Kurkianea869482019-04-09 15:16:11 -04001package sarama
2
3type CoordinatorType int8
4
5const (
6 CoordinatorGroup CoordinatorType = 0
7 CoordinatorTransaction CoordinatorType = 1
8)
9
10type FindCoordinatorRequest struct {
11 Version int16
12 CoordinatorKey string
13 CoordinatorType CoordinatorType
14}
15
16func (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
28func (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
46func (f *FindCoordinatorRequest) key() int16 {
47 return 10
48}
49
50func (f *FindCoordinatorRequest) version() int16 {
51 return f.Version
52}
53
54func (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}