doujiang24 / lua-resty-kafka

Lua kafka client driver for the Openresty based on the cosocket API
BSD 3-Clause "New" or "Revised" License
804 stars 275 forks source link

return empty brokers #9

Open hy05190134 opened 9 years ago

hy05190134 commented 9 years ago

local cli = client:new(broker_list)
local brokers, partitions = cli:fetch_metadata(kafka.topic)
if not brokers then
ngx.log(ngx.ERR, "fetch_metadata failed, err:", partitions)
end
ngx.log(ngx.ERR, "brokers: ", #brokers, "; partitions: ", cjson.encode(partitions))

I use the code above in my macos environment and I can ensure the broker_list is available and is it bug to just return a empty brokers? but partitions info is ok

doujiang24 commented 9 years ago

@hy05190134 brokers is not empty, cause it may not be an array, this depend on broker.id in your kafka config

you can try lua ngx.say("brokers: ", cjson.encode(brokers), "; partitions: ", cjson.encode(partitions))

hy05190134 commented 9 years ago

cjson.encode(brokers) return nil which I ever use

hy05190134 commented 9 years ago

but I directly use producer:new and send function, I find it works well

doujiang24 commented 9 years ago

@hy05190134 It sounds impossible, can you try the sample code again and show me the original result ?

leocook commented 8 years ago

I got the same problem