Skip to content

Commit

Permalink
Merge pull request #932 from ploxiln/diskqueue_logf
Browse files Browse the repository at this point in the history
nsqd: diskqueue now takes AppLogFunc instead of Logger
  • Loading branch information
mreiferson authored Aug 27, 2017
2 parents a73c39f + 2ee959a commit e2aa615
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
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

0 comments on commit e2aa615

Please sign in to comment.