segmentio/nsq-go

Json Marshaling Error in Lookup

trvsysadmin opened this issue · 4 comments

In file lookup.go, line 55, there seems to be an inconsistency of the struct used to marshal the json returned by nsqdlookup. Currently it is:

v := struct {
  StatusCode int          `json:"status_code"`
  StatusTxt  string       `json:"status_txt"`
  Data       LookupResult `json:"data"`
}{}

whereas v should simply be

v := LookupResult{}

Because http://nsqd/lookup?topic=hello returns

{
	"channels": ["chan1", "world"],
	"producers": [{
		"remote_address": "127.0.0.1:34444",
		"hostname": "blah",
		"broadcast_address": "blah",
		"tcp_port": 4150,
		"http_port": 4151,
		"version": "1.0.0-compat"
	}]
}

Did we do something wrong or misunderstood something? Were you supposed to insert StatusCode and StatusTxt into retList when you call c.doAll in line 39?

Note: We are using nsq 1.0.0-compat (https://github.com/nsqio/nsq/releases/tag/v1.0.0-compat) on standard Ubuntu 16 .

It might be an API that changed between nsq 0.3.8 and 1.0, we are still on 0.3.8 at segment so it may be why we haven’t had issues with it.

If you want to send a fix I’ll be happy to take a look and merge it.

Hit that issue too. PR coming..

please fix it