feat: code cleanup
This commit is contained in:
20
consumer.go
20
consumer.go
@@ -15,10 +15,6 @@ import (
|
||||
)
|
||||
|
||||
// InitConsumer 初始化消费者
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 8:45 下午 2021/9/22
|
||||
func InitConsumer(topic string, consumerGroup string, hostList []string, cfg *sarama.Config) (*Consumer, error) {
|
||||
if nil == cfg {
|
||||
cfg = sarama.NewConfig()
|
||||
@@ -36,10 +32,6 @@ func InitConsumer(topic string, consumerGroup string, hostList []string, cfg *sa
|
||||
}
|
||||
|
||||
// Consumer ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 8:52 下午 2021/9/22
|
||||
type Consumer struct {
|
||||
topic string
|
||||
host []string
|
||||
@@ -50,10 +42,6 @@ type Consumer struct {
|
||||
}
|
||||
|
||||
// init ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 8:55 下午 2021/9/22
|
||||
func (c *Consumer) init() error {
|
||||
var (
|
||||
err error
|
||||
@@ -68,10 +56,6 @@ func (c *Consumer) init() error {
|
||||
}
|
||||
|
||||
// Consume 消费消息
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 9:04 下午 2021/9/22
|
||||
func (c *Consumer) Consume(dataHandler IConsumeDataHandler) {
|
||||
ctx := context.Background()
|
||||
for {
|
||||
@@ -106,10 +90,6 @@ func (h consumerGroupHandler) ConsumeClaim(sess sarama.ConsumerGroupSession, cla
|
||||
}
|
||||
|
||||
// Destroy ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 8:59 下午 2021/9/22
|
||||
func (c *Consumer) Destroy() {
|
||||
_ = c.consumerGroupInstance.Close()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user