@@ -132,16 +132,17 @@ func (c *consumer) Partitions(topic string) ([]int32, error) {
132
132
133
133
func (c * consumer ) ConsumePartition (topic string , partition int32 , offset int64 ) (PartitionConsumer , error ) {
134
134
child := & partitionConsumer {
135
- consumer : c ,
136
- conf : c .conf ,
137
- topic : topic ,
138
- partition : partition ,
139
- messages : make (chan * ConsumerMessage , c .conf .ChannelBufferSize ),
140
- errors : make (chan * ConsumerError , c .conf .ChannelBufferSize ),
141
- feeder : make (chan * FetchResponse , 1 ),
142
- trigger : make (chan none , 1 ),
143
- dying : make (chan none ),
144
- fetchSize : c .conf .Consumer .Fetch .Default ,
135
+ consumer : c ,
136
+ conf : c .conf ,
137
+ topic : topic ,
138
+ partition : partition ,
139
+ messages : make (chan * ConsumerMessage , c .conf .ChannelBufferSize ),
140
+ errors : make (chan * ConsumerError , c .conf .ChannelBufferSize ),
141
+ feeder : make (chan * FetchResponse , 1 ),
142
+ preferredReadReplica : invalidPreferredReplicaID ,
143
+ trigger : make (chan none , 1 ),
144
+ dying : make (chan none ),
145
+ fetchSize : c .conf .Consumer .Fetch .Default ,
145
146
}
146
147
147
148
if err := child .chooseStartingOffset (offset ); err != nil {
@@ -605,7 +606,9 @@ func (child *partitionConsumer) parseResponse(response *FetchResponse) ([]*Consu
605
606
606
607
consumerBatchSizeMetric .Update (int64 (nRecs ))
607
608
608
- child .preferredReadReplica = block .PreferredReadReplica
609
+ if block .PreferredReadReplica != invalidPreferredReplicaID {
610
+ child .preferredReadReplica = block .PreferredReadReplica
611
+ }
609
612
610
613
if nRecs == 0 {
611
614
partialTrailingMessage , err := block .isPartial ()
0 commit comments