Skip to content

Commit

Permalink
Merge pull request #284 from crawlab-team/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
tikazyq authored Oct 28, 2019
2 parents 32f2323 + 6814b6b commit c6da87e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
2 changes: 1 addition & 1 deletion backend/services/msg_handler/msg_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 0 additions & 21 deletions backend/utils/helpers.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package utils

import (
"context"
"crawlab/database"
"crawlab/entity"
"encoding/json"
"github.com/apex/log"
Expand Down Expand Up @@ -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
}

0 comments on commit c6da87e

Please sign in to comment.