Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consumer: reduce ticker allocations #1028

Merged
merged 1 commit into from
Feb 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,20 +441,20 @@ func (child *partitionConsumer) HighWaterMarkOffset() int64 {

func (child *partitionConsumer) responseFeeder() {
var msgs []*ConsumerMessage
msgSent := false
expiryTicker := time.NewTicker(child.conf.Consumer.MaxProcessingTime)
firstAttempt := true

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:
select {
case child.messages <- msg:
msgSent = true
firstAttempt = true
case <-expiryTicker.C:
if !msgSent {
if !firstAttempt {
child.responseResult = errTimedOut
child.broker.acks.Done()
for _, msg = range msgs[i:] {
Expand All @@ -465,16 +465,16 @@ feederLoop:
} else {
// current message has not been sent, return to select
// statement
msgSent = false
firstAttempt = false
goto messageSelect
}
}
}

expiryTicker.Stop()
child.broker.acks.Done()
}

expiryTicker.Stop()
close(child.messages)
close(child.errors)
}
Expand Down