-
Notifications
You must be signed in to change notification settings - Fork 43
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
Change listener to be plugable #79
Change listener to be plugable #79
Conversation
2a8f164
to
9cfdc05
Compare
napalm_logs/listener/kafka.py
Outdated
signal.signal(signal.SIGTERM, self._exit_gracefully) | ||
self.__up = True | ||
try: | ||
self.consumer = kafka.KafkaConsumer(bootstrap_servers='{}:{}'.format(self.address, self.port), group_id='napalm-logs') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This indentation doesn't look fine. Can you check?
Also, when passing multiple kwargs, please separate them on new lines.
napalm_logs/listener/kafka.py
Outdated
self.consumer = kafka.KafkaConsumer(bootstrap_servers='{}:{}'.format(self.address, self.port), group_id='napalm-logs') | ||
except kafka.errors.NoBrokersAvailable as err: | ||
log.error(err, exc_info=True) | ||
raise NapalmLogsException(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should introduce a new exception class for listener.
napalm_logs/listener/tcp.py
Outdated
''' | ||
signal.signal(signal.SIGTERM, self._exit_gracefully) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like unidented block.
napalm_logs/listener/udp.py
Outdated
''' | ||
Start listening for messages | ||
''' | ||
signal.signal(signal.SIGTERM, self._exit_gracefully) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
napalm_logs/listener/udp.py
Outdated
except socket.error as msg: | ||
error_string = 'Unable to bind to port {} on {}: {}'.format(self.port, self.address, msg) | ||
log.error(error_string, exc_info=True) | ||
raise BindException(error_string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we introduce a new exception class, don't forger to raise it here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good overall, just some small improvements, please.
napalm_logs/transport/base.py
Outdated
@@ -14,8 +14,5 @@ def __init__(self, addr, port): | |||
def start(self): | |||
pass | |||
|
|||
def publish(self, obj): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added back, this was unintended
9cfdc05
to
4574a4e
Compare
I have changed the listener to be plugable in the same way that the publisher transport is. I have also added a kafka listener too.
4574a4e
to
7a806b8
Compare
I have changed the listener to be plugable in the same way that the
publisher transport is.
I have also added a kafka listener too.