Skip to content

Commit

Permalink
convert nsqd lookup_peer to use app logf()
Browse files Browse the repository at this point in the history
  • Loading branch information
ploxiln committed May 26, 2017
1 parent 46fd991 commit 91a0f33
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion nsqd/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (n *NSQD) lookupLoop() {
continue
}
n.logf(LOG_INFO, "LOOKUP(%s): adding peer", host)
lookupPeer := newLookupPeer(host, n.getOpts().MaxBodySize, n.getOpts().Logger,
lookupPeer := newLookupPeer(host, n.getOpts().MaxBodySize, n.logf,
connectCallback(n, hostname, syncTopicChan))
lookupPeer.Command(nil) // start the connection
lookupPeers = append(lookupPeers, lookupPeer)
Expand Down
9 changes: 5 additions & 4 deletions nsqd/lookup_peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"github.com/nsqio/go-nsq"
"github.com/nsqio/nsq/internal/lg"
)

// lookupPeer is a low-level type for connecting/reading/writing to nsqlookupd
Expand All @@ -16,7 +17,7 @@ import (
// gracefully (i.e. it is all handled by the library). Clients can simply use the
// Command interface to perform a round-trip.
type lookupPeer struct {
l Logger
logf lg.AppLogFunc
addr string
conn net.Conn
state int32
Expand All @@ -36,9 +37,9 @@ type peerInfo struct {
// newLookupPeer creates a new lookupPeer instance connecting to the supplied address.
//
// The supplied connectCallback will be called *every* time the instance connects.
func newLookupPeer(addr string, maxBodySize int64, l Logger, connectCallback func(*lookupPeer)) *lookupPeer {
func newLookupPeer(addr string, maxBodySize int64, l lg.AppLogFunc, connectCallback func(*lookupPeer)) *lookupPeer {
return &lookupPeer{
l: l,
logf: l,
addr: addr,
state: stateDisconnected,
maxBodySize: maxBodySize,
Expand All @@ -48,7 +49,7 @@ func newLookupPeer(addr string, maxBodySize int64, l Logger, connectCallback fun

// Connect will Dial the specified address, with timeouts
func (lp *lookupPeer) Connect() error {
lp.l.Output(2, fmt.Sprintf("LOOKUP connecting to %s", lp.addr))
lp.logf(lg.INFO, "LOOKUP connecting to %s", lp.addr)
conn, err := net.DialTimeout("tcp", lp.addr, time.Second)
if err != nil {
return err
Expand Down

0 comments on commit 91a0f33

Please sign in to comment.