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 -}