(pe packetEncoder)
| 77 | } |
| 78 | |
| 79 | func (r *OffsetFetchRequest) encode(pe packetEncoder) (err error) { |
| 80 | if r.Version < 0 || r.Version > 8 { |
| 81 | return PacketEncodingError{"invalid or unsupported OffsetFetchRequest version field"} |
| 82 | } |
| 83 | |
| 84 | if r.RequireStable && r.Version < 7 { |
| 85 | return PacketEncodingError{"requireStable is not supported. use version 7 or later"} |
| 86 | } |
| 87 | |
| 88 | if r.Version >= 8 { |
| 89 | if len(r.Groups) == 0 { |
| 90 | return PacketEncodingError{"version 8 or later requires Groups to be populated"} |
| 91 | } |
| 92 | if err := pe.putArrayLength(len(r.Groups)); err != nil { |
| 93 | return err |
| 94 | } |
| 95 | for _, g := range r.Groups { |
| 96 | if err := pe.putString(g.GroupId); err != nil { |
| 97 | return err |
| 98 | } |
| 99 | |
| 100 | // nil Partitions encodes as null topics array (fetch all) |
| 101 | topicCount := len(g.Partitions) |
| 102 | if g.Partitions == nil { |
| 103 | topicCount = -1 |
| 104 | } |
| 105 | if err := pe.putArrayLength(topicCount); err != nil { |
| 106 | return err |
| 107 | } |
| 108 | for topic, partitions := range g.Partitions { |
| 109 | if err := pe.putString(topic); err != nil { |
| 110 | return err |
| 111 | } |
| 112 | if err := pe.putInt32Array(partitions); err != nil { |
| 113 | return err |
| 114 | } |
| 115 | pe.putEmptyTaggedFieldArray() |
| 116 | } |
| 117 | |
| 118 | pe.putEmptyTaggedFieldArray() |
| 119 | } |
| 120 | |
| 121 | pe.putBool(r.RequireStable) |
| 122 | pe.putEmptyTaggedFieldArray() |
| 123 | return nil |
| 124 | } |
| 125 | |
| 126 | if len(r.Groups) > 1 { |
| 127 | return PacketEncodingError{"multiple groups require version 8 or later"} |
| 128 | } |
| 129 | |
| 130 | consumerGroup := r.ConsumerGroup |
| 131 | partitions := r.partitions |
| 132 | if consumerGroup == "" && len(r.Groups) == 1 { |
| 133 | consumerGroup = r.Groups[0].GroupId |
| 134 | partitions = r.Groups[0].Partitions |
| 135 | } |
| 136 |
nothing calls this directly
no test coverage detected