From d7428ad074b53ab47b24591cb1f569a028142bc4 Mon Sep 17 00:00:00 2001 From: faceair Date: Wed, 24 Jan 2018 15:15:20 +0800 Subject: [PATCH] Consumer: reduce ticker allocations --- consumer.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/consumer.go b/consumer.go index 506e657f0d..3b225b128f 100644 --- a/consumer.go +++ b/consumer.go @@ -442,11 +442,11 @@ func (child *partitionConsumer) HighWaterMarkOffset() int64 { func (child *partitionConsumer) responseFeeder() { var msgs []*ConsumerMessage msgSent := false + expiryTicker := time.NewTicker(child.conf.Consumer.MaxProcessingTime) feederLoop: for response := range child.feeder { msgs, child.responseResult = child.parseResponse(response) - expiryTicker := time.NewTicker(child.conf.Consumer.MaxProcessingTime) for i, msg := range msgs { messageSelect: @@ -471,10 +471,10 @@ feederLoop: } } - expiryTicker.Stop() child.broker.acks.Done() } + expiryTicker.Stop() close(child.messages) close(child.errors) }