Update the Hermann::Discovery::Zookeeper API to return an Array of brokers more suitable for Hermann::Producer

This commit is contained in:
R. Tyler Croy 2014-10-30 10:05:34 -07:00
parent 8400cfdc15
commit 3c9c234c43
3 changed files with 7 additions and 7 deletions

View File

@ -24,8 +24,7 @@ module Hermann
# tickTime (as set in the server configuration) and a maximum
# of 20 times the tickTime2 times the tick time set on server"
#
# @return [String] comma separated list of brokers
#
# @return [Array] List of brokers from ZK
# @raises [NoBrokersError] if could not discover brokers thru zookeeper
def get_brokers(timeout=0)
brokers = []
@ -35,7 +34,7 @@ module Hermann
if brokers.empty?
raise Hermann::Errors::NoBrokersError
end
brokers.join(',')
return brokers
end
private
@ -82,4 +81,4 @@ module Hermann
end
end
end
end
end

View File

@ -18,7 +18,7 @@ describe Hermann::Discovery::Zookeeper do
context 'with valid brokers' do
let(:brokers) { broker_array }
it 'gets valid string' do
expect(subject.get_brokers).to eq 'f:1,a:2'
expect(subject.get_brokers).to eq broker_array
end
end
context 'with no brokers' do

View File

@ -1,4 +1,5 @@
kafka:
brokers: "localhost:12345"
brokers:
- "localhost:12345"
topic: "testing-topic"
zookeepers: "localhost:2181"
zookeepers: "localhost:2181"