Skip to content
This repository has been archived by the owner on Jun 14, 2023. It is now read-only.

Update kafka.go #56

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

liufugen-yewu
Copy link

@liufugen-yewu liufugen-yewu commented Nov 21, 2022

KafkaReport component bug repair

kafkaReport组件bug修复
@wu-sheng
Copy link
Member

You need to update the PR title and codes/comments in English, also, you should describe the bug the PR content.

@liufugen-yewu
Copy link
Author

The current bug is an kafka connection, and you can only report data once, because there is no processing of the return message of data reporting.
So a kafka connection is required for each request.
The current submission can solve the problem.

@@ -297,6 +297,17 @@ func (r *kafkaReporter) Close() {
r.logger.Print(err)
}
}
//循环处理上报信息的结果信息,以实现kafka单次连接多次上报。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should be updated as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

@wu-sheng wu-sheng requested a review from arugal November 21, 2022 09:11
@wu-sheng
Copy link
Member

@arugal Could you recheck on Kafka API?

select {
case <-r.producer.Successes():
case err := <- r.producer.Errors():
r.logger.Fatalf( "kafkaReport readBackMessage error detail is %s",err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using the log.Errorf output will do, which will cause the process to end

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can check the revised document to confirm. github.com/Shopify/sarama/async_producer.go

// Successes is the success output channel back to the user when Return.Successes is
// enabled. If Return.Successes is true, you MUST read from this channel or the
// Producer will deadlock. It is suggested that you send and read messages
// together in a single select statement.
Successes() <-chan *ProducerMessage

// Errors is the error output channel back to the user. You MUST read from this
// channel or the Producer will deadlock when the channel is full. Alternatively,
// you can set Producer.Return.Errors in your config to false, which prevents
// errors to be returned.
Errors() <-chan *ProducerError

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants