From 509f1f0c121189fe3f441efca0bd2b062febd586 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期五, 20 十月 2023 15:50:27 +0800
Subject: [PATCH] fix
---
pkg/nsqclient/consumer.go | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/pkg/nsqclient/consumer.go b/pkg/nsqclient/consumer.go
index a0df0b0..644fba3 100644
--- a/pkg/nsqclient/consumer.go
+++ b/pkg/nsqclient/consumer.go
@@ -1,6 +1,7 @@
package nsqclient
import (
+ "apsClient/pkg/logx"
"context"
"fmt"
"time"
@@ -18,7 +19,7 @@
channel string
}
-func NewNsqConsumer(ctx context.Context, topic, channel string, options ...func(*nsq.Config)) (*NsqConsumer, error) {
+func NewNsqConsumer(topic, channel string, options ...func(*nsq.Config)) (*NsqConsumer, error) {
conf := nsq.NewConfig()
conf.MaxAttempts = 0
conf.MsgTimeout = 10 * time.Minute // 榛樿涓�涓秷鎭渶澶氳兘澶勭悊鍗佸垎閽燂紝鍚﹀垯灏变細閲嶆柊涓㈠叆闃熷垪
@@ -33,7 +34,6 @@
}
return &NsqConsumer{
consumer: consumer,
- ctx: ctx,
topic: topic,
channel: channel,
}, nil
@@ -90,9 +90,10 @@
for {
select {
case <-n.ctx.Done():
- fmt.Println("[%s] %s,%s", "stop consumer", n.topic, n.channel)
+ logx.Infof("[%s]%s stop consumer...", n.topic, n.channel)
n.consumer.Stop()
- fmt.Println("[%s] %s,%s", "stop consumer success", n.topic, n.channel)
+ <-n.consumer.StopChan
+ logx.Infof("[%s]%s stop consumer success", n.topic, n.channel)
return nil
}
}
--
Gitblit v1.8.0