From 9427283e3a6689c52cd2ba3a0734a49ccab28fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=99=AF=E9=98=B3?= <1656488874@qq.com> Date: Mon, 28 Oct 2019 13:51:12 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=BE=AA=E7=8E=AF=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/services/msg_handler/msg_log.go | 2 +- backend/utils/helpers.go | 21 --------------------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/backend/services/msg_handler/msg_log.go b/backend/services/msg_handler/msg_log.go index 993fad9a4..2a17ed99b 100644 --- a/backend/services/msg_handler/msg_log.go +++ b/backend/services/msg_handler/msg_log.go @@ -40,7 +40,7 @@ func (g *Log) get() error { msgSd.Log = utils.BytesToString(logStr) } // 发布消息给主节点 - if err := utils.Pub(constants.ChannelMasterNode, msgSd); err != nil { + if err := database.Pub(constants.ChannelMasterNode, msgSd); err != nil { log.Errorf("pub log to master node error: %s", err.Error()) debug.PrintStack() return err diff --git a/backend/utils/helpers.go b/backend/utils/helpers.go index 1c8c96e30..541d90027 100644 --- a/backend/utils/helpers.go +++ b/backend/utils/helpers.go @@ -1,8 +1,6 @@ package utils import ( - "context" - "crawlab/database" "crawlab/entity" "encoding/json" "github.com/apex/log" @@ -42,22 +40,3 @@ func Close(c io.Closer) { log.WithError(err).Error("关闭资源文件失败。") } } - -func Pub(channel string, msg entity.NodeMessage) error { - if _, err := database.RedisClient.Publish(channel, GetJson(msg)); err != nil { - log.Errorf("publish redis error: %s", err.Error()) - debug.PrintStack() - return err - } - return nil -} - -func Sub(channel string, consume database.ConsumeFunc) error { - ctx := context.Background() - if err := database.RedisClient.Subscribe(ctx, consume, channel); err != nil { - log.Errorf("subscribe redis error: %s", err.Error()) - debug.PrintStack() - return err - } - return nil -}