wistia / nsq-ruby

NSQ Ruby client
MIT License
68 stars 27 forks source link

NSQ Discovery is broken on v1.0.0-compat #37

Closed pacoguzman closed 7 years ago

pacoguzman commented 7 years ago

With the last release of NSQ v1.0.0-compat the way Nsq::Discovery class gets nsqds is not working any more. The response from nsqlookupd just changed:

$ http --json "http://127.0.0.1:4161/lookup?ts=1490345916&topic=pushes"
HTTP/1.1 200 OK
Content-Length: 191
Content-Type: application/json; charset=utf-8
Date: Fri, 24 Mar 2017 09:07:18 GMT
X-Nsq-Content-Type: nsq; version=1.0

{
    "channels": [
        "pushes"
    ],
    "producers": [
        {
            "broadcast_address": "127.0.0.1",
            "hostname": "9b61e4e768be",
            "http_port": 4151,
            "remote_address": "172.17.0.3:47742",
            "tcp_port": 4150,
            "version": "1.0.0-compat"
        }
    ]
}

Which is not what is expected by the code

        if data['data'] && data['data']['producers']
          data['data']['producers'].map do |producer|
            "#{producer['broadcast_address']}:#{producer['tcp_port']}"
          end
        else
          []
        end

I'm going to work in making compatible and I'll provide a PR.

bschwartz commented 7 years ago

Fixed via #38