Skip to content
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

Merged
merged 1 commit into from
Jun 13, 2017

Conversation

luke-orden
Copy link
Collaborator

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.

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')
Copy link
Member

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.

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)
Copy link
Member

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.

'''
signal.signal(signal.SIGTERM, self._exit_gracefully)
Copy link
Member

Choose a reason for hiding this comment

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

Looks like unidented block.

'''
Start listening for messages
'''
signal.signal(signal.SIGTERM, self._exit_gracefully)
Copy link
Member

Choose a reason for hiding this comment

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

Same here

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)
Copy link
Member

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.

Copy link
Member

@mirceaulinic mirceaulinic left a 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.

@@ -14,8 +14,5 @@ def __init__(self, addr, port):
def start(self):
pass

def publish(self, obj):
Copy link
Member

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?

Copy link
Collaborator Author

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

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.
@mirceaulinic mirceaulinic merged commit 613e988 into napalm-automation:master Jun 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants