Skip to content

Commit

Permalink
[refactor] pass saramaMessageWrapper by value (jaegertracing#1818)
Browse files Browse the repository at this point in the history
Signed-off-by: Prithvi Raj <[email protected]>
  • Loading branch information
vprithvi authored and yurishkuro committed Sep 25, 2019
1 parent 1672b00 commit 404ce68
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/ingester/app/consumer/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (c *Consumer) handleMessages(pc sc.PartitionConsumer) {
defer msgProcessor.Close()
}

msgProcessor.Process(&saramaMessageWrapper{msg})
msgProcessor.Process(saramaMessageWrapper{msg})

case <-deadlockDetector.closePartitionChannel():
c.logger.Info("Closing partition due to inactivity", zap.Int32("partition", pc.Partition()))
Expand Down
2 changes: 1 addition & 1 deletion cmd/ingester/app/consumer/consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestSaramaConsumerWrapper_start_Messages(t *testing.T) {
isProcessed := sync.WaitGroup{}
isProcessed.Add(1)
mp := &pmocks.SpanProcessor{}
mp.On("Process", &saramaMessageWrapper{msg}).Return(func(msg processor.Message) error {
mp.On("Process", saramaMessageWrapper{msg}).Return(func(msg processor.Message) error {
isProcessed.Done()
return nil
})
Expand Down
10 changes: 5 additions & 5 deletions cmd/ingester/app/consumer/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ type saramaMessageWrapper struct {
*sarama.ConsumerMessage
}

func (m *saramaMessageWrapper) Key() []byte {
func (m saramaMessageWrapper) Key() []byte {
return m.ConsumerMessage.Key
}

func (m *saramaMessageWrapper) Value() []byte {
func (m saramaMessageWrapper) Value() []byte {
return m.ConsumerMessage.Value
}

func (m *saramaMessageWrapper) Topic() string {
func (m saramaMessageWrapper) Topic() string {
return m.ConsumerMessage.Topic
}

func (m *saramaMessageWrapper) Partition() int32 {
func (m saramaMessageWrapper) Partition() int32 {
return m.ConsumerMessage.Partition
}

func (m *saramaMessageWrapper) Offset() int64 {
func (m saramaMessageWrapper) Offset() int64 {
return m.ConsumerMessage.Offset
}

0 comments on commit 404ce68

Please sign in to comment.