Skip to content

Support for multiple hosts on KafkaClient boostrap (improves on #70) #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 27, 2014

Conversation

mrtheb
Copy link
Collaborator

@mrtheb mrtheb commented Feb 9, 2014

Allow KafkaClient to take in a list of brokers for bootstrapping (improves in #70)

Proposed resolution for enhancement #25

This change breaks the KafkaClient constructor API but replacing the host and port parameters with hosts represented as a comma-separated list of host:port.

E.g. as comma-separated string of host:port

kafka = KafkaClient("localhost:9092, localhost:9093")

or as list of host:port

kafka = KafkaClient(['localhost:9092', 'localhost:9093'])

It also introduces the mock library for unit testing.

Note: some unit tests are still marked as skipped until disabling recursion on load_metadata_for_topics_, an issue I found during testing (#68). They are enabled in #109


res = host_port.split(':')
host = res[0]
port = int(res[1]) if len(res) > 1 else 9092
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default port should be a constant: DEFAULT_KAKFA_PORT = 9092

@rdiomar
Copy link
Collaborator

rdiomar commented Feb 11, 2014

Looks good! I just had a couple of minor comments. Thanks for all the unit test work!

result = []
for host_port in hosts:

res = host_port.split(':')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably want host_port.strip().split(':') to allow for spaces around the commas

rdiomar added a commit that referenced this pull request Feb 27, 2014
Support for multiple hosts on KafkaClient boostrap (improves on #70)
@rdiomar rdiomar merged commit ab89a44 into dpkp:master Feb 27, 2014
susman pushed a commit to liquidm/collectd2kafka that referenced this pull request Jul 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants