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

nsqd: diskqueue now takes AppLogFunc instead of Logger #932

Merged
merged 1 commit into from
Aug 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion Godeps
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ github.com/bitly/timer_metrics afad1794bb13e2a094720aeb27c088aa64564895
github.com/blang/semver 9bf7bff48b0388cb75991e58c6df7d13e982f1f2
github.com/julienschmidt/httprouter 6aacfd5ab513e34f7e64ea9627ab9670371b34e7
github.com/judwhite/go-svc/svc 63c12402f579f0bdf022653c821a1aa5d7544f01
github.com/nsqio/go-diskqueue d7805f889b023afcd5b8933e815ce9ba36327333
github.com/nsqio/go-diskqueue 0681a1afee1245efa503b7543989fc26d8f268bc
11 changes: 9 additions & 2 deletions nsqd/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/nsqio/go-diskqueue"
"github.com/nsqio/nsq/internal/lg"
"github.com/nsqio/nsq/internal/pqueue"
"github.com/nsqio/nsq/internal/quantile"
)
Expand Down Expand Up @@ -94,16 +95,22 @@ func NewChannel(topicName string, channelName string, ctx *context,
c.ephemeral = true
c.backend = newDummyBackendQueue()
} else {
dqLogf := func(level diskqueue.LogLevel, f string, args ...interface{}) {
opts := ctx.nsqd.getOpts()
lg.Logf(opts.Logger, opts.logLevel, lg.LogLevel(level), f, args...)
}
// backend names, for uniqueness, automatically include the topic...
backendName := getBackendName(topicName, channelName)
c.backend = diskqueue.New(backendName,
c.backend = diskqueue.New(
backendName,
ctx.nsqd.getOpts().DataPath,
ctx.nsqd.getOpts().MaxBytesPerFile,
int32(minValidMsgLength),
int32(ctx.nsqd.getOpts().MaxMsgSize)+minValidMsgLength,
ctx.nsqd.getOpts().SyncEvery,
ctx.nsqd.getOpts().SyncTimeout,
ctx.nsqd.getOpts().Logger)
dqLogf,
)
}

c.ctx.nsqd.Notify(c)
Expand Down
11 changes: 9 additions & 2 deletions nsqd/topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/nsqio/go-diskqueue"
"github.com/nsqio/nsq/internal/lg"
"github.com/nsqio/nsq/internal/quantile"
"github.com/nsqio/nsq/internal/util"
)
Expand Down Expand Up @@ -57,14 +58,20 @@ func NewTopic(topicName string, ctx *context, deleteCallback func(*Topic)) *Topi
t.ephemeral = true
t.backend = newDummyBackendQueue()
} else {
t.backend = diskqueue.New(topicName,
dqLogf := func(level diskqueue.LogLevel, f string, args ...interface{}) {
opts := ctx.nsqd.getOpts()
lg.Logf(opts.Logger, opts.logLevel, lg.LogLevel(level), f, args...)
}
t.backend = diskqueue.New(
topicName,
ctx.nsqd.getOpts().DataPath,
ctx.nsqd.getOpts().MaxBytesPerFile,
int32(minValidMsgLength),
int32(ctx.nsqd.getOpts().MaxMsgSize)+minValidMsgLength,
ctx.nsqd.getOpts().SyncEvery,
ctx.nsqd.getOpts().SyncTimeout,
ctx.nsqd.getOpts().Logger)
dqLogf,
)
}

t.waitGroup.Wrap(func() { t.messagePump() })
Expand Down