Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add log nsq backend and nsq publish supported #12

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add inter log
  • Loading branch information
[email protected] committed Apr 19, 2018
commit 06aba348040d29ba2cb2e09b8d78f9a3c1a20212
10 changes: 5 additions & 5 deletions db/mq/mynsq/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ func (t *topicInfo) connect(channelName string, nsqdAddr []string, debug bool) {
time.Sleep(time.Duration(sleepSeconds) * time.Second)
continue
}
// if debug {
// t.consumer.SetLogger(log., gonsq.LogLevelDebug)
// } else {
// t.consumer.SetLogger(fmt.GetLogger(), gonsq.LogLevelWarning)
// }
if debug {
t.consumer.SetLogger(&interLog{}, gonsq.LogLevelDebug)
} else {
t.consumer.SetLogger(&interLog{}, gonsq.LogLevelWarning)
}
fmt.Printf("连接nsqd(%v)成功\n", nsqdAddr)
break
}
Expand Down
10 changes: 10 additions & 0 deletions db/mq/mynsq/nsq.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package mynsq

import (
"fmt"

"github.com/cuigh/auxo/config"
"github.com/cuigh/auxo/errors"
)
Expand All @@ -16,6 +18,14 @@ type Options struct {
ChannelName string
}

type interLog struct {
}

func (il *interLog) Output(calldepth int, s string) error {
fmt.Println(s)
return nil
}

func loadOptions() (*Options, error) {
key := "global.mq.nsq"
if !config.Exist(key) {
Expand Down
2 changes: 1 addition & 1 deletion db/mq/mynsq/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func create() (d interface{}, err error) {
err = errors.New("初始化 nsq producer 失败, err:" + err.Error())
return
}
// w.SetLogger(fmt.GetLogger(), gonsq.LogLevelDebug)
w.SetLogger(&interLog{}, gonsq.LogLevelDebug)
ret := &myProducer{producer: w}
d = interface{}(ret)
return d, err
Expand Down