Просмотр исходного кода

Fix an additional possible alignment issue

Also add comments so future me knows why those variables are all by
themselves at the top of the structs.
Evan Huus 9 лет назад
Родитель
Сommit
7f63d35b79
2 измененных файлов с 8 добавлено и 8 удалено
  1. 7 7
      consumer.go
  2. 1 1
      mocks/consumer.go

+ 7 - 7
consumer.go

@@ -289,10 +289,11 @@ type PartitionConsumer interface {
 }
 
 type partitionConsumer struct {
-	consumer  *consumer
-	conf      *Config
-	topic     string
-	partition int32
+	highWaterMarkOffset int64 // must be at the top of the struct because https://golang.org/pkg/sync/atomic/#pkg-note-BUG
+	consumer            *consumer
+	conf                *Config
+	topic               string
+	partition           int32
 
 	broker   *brokerConsumer
 	messages chan *ConsumerMessage
@@ -302,9 +303,8 @@ type partitionConsumer struct {
 	trigger, dying chan none
 	responseResult error
 
-	fetchSize           int32
-	offset              int64
-	highWaterMarkOffset int64
+	fetchSize int32
+	offset    int64
 }
 
 var errTimedOut = errors.New("timed out feeding messages to the user") // not user-facing

+ 1 - 1
mocks/consumer.go

@@ -178,7 +178,7 @@ func (c *Consumer) ExpectConsumePartition(topic string, partition int32, offset
 // Errors and Messages channel, you should specify what values will be provided on these
 // channels using YieldMessage and YieldError.
 type PartitionConsumer struct {
-	highWaterMarkOffset     int64
+	highWaterMarkOffset     int64 // must be at the top of the struct because https://golang.org/pkg/sync/atomic/#pkg-note-BUG
 	l                       sync.Mutex
 	t                       ErrorReporter
 	topic                   string