-
Notifications
You must be signed in to change notification settings - Fork 36
feat(notification-center): Add LogEvent notification #204
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
feat(notification-center): Add LogEvent notification #204
Conversation
…into mnoman/log_event_notification # Conflicts: # tests/test_event_processor.py
tests/test_notification_center.py
Outdated
@@ -219,6 +235,7 @@ def test_clear_all_notification_listeners(self): | |||
test_notification_center.clear_all_notification_listeners() | |||
|
|||
for notification_type in notification_center.NOTIFICATION_TYPES: | |||
print(notification_type) |
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.
Remove
…/python-sdk into mnoman/log_event_notification
…/python-sdk into mnoman/log_event_notification
optimizely/event/event_processor.py
Outdated
@@ -23,7 +23,7 @@ | |||
from optimizely import logger as _logging | |||
from optimizely.closeable import Closeable | |||
from optimizely.event_dispatcher import EventDispatcher as default_event_dispatcher | |||
from optimizely.helpers import validator | |||
from optimizely.helpers import validator, enums |
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.
nit. I'd recommend splitting up imports into separate lines. Just a conventional thing.
optimizely/event/event_processor.py
Outdated
@@ -60,7 +61,8 @@ def __init__(self, | |||
event_queue=None, | |||
batch_size=None, | |||
flush_interval=None, | |||
timeout_interval=None): | |||
timeout_interval=None, | |||
notification_center=None): |
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.
Can you add some good explanations for all the fields here. Something like: https://github.com/optimizely/python-sdk/blob/master/optimizely/optimizely.py#L42-L59
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.
Need some better documentation.
this PR is getting failed on travis. Need to check. |
optimizely/event/event_processor.py
Outdated
Args: | ||
event_dispatcher: Provides a dispatch_event method which if given a URL and params sends a request to it. | ||
logger: Provides a log method to log messages. By default nothing would be logged. | ||
default_start: Optional boolean param which starts the consumer thread if set to True. |
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.
Not entirely sure on this variable name. How about start_on_init
?
optimizely/event/event_processor.py
Outdated
batch_size: Optional param which defines the upper limit of the number of events in event_queue after which | ||
the event_queue will be flushed. | ||
flush_interval: Optional param which defines the time in milliseconds after which event_queue will be flushed. | ||
timeout_interval: Optional param which defines the time in milliseconds before joining the consumer |
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.
I'd like for us to have any time intervals in seconds like we already have for datafile management.
# Conflicts: # optimizely/event/event_processor.py # tests/test_event_processor.py
# Conflicts: # optimizely/event/event_processor.py
# Conflicts: # optimizely/event/event_processor.py
…/python-sdk into mnoman/log_event_notification
@@ -195,6 +200,12 @@ def _flush_queue(self): | |||
|
|||
log_event = EventFactory.create_log_event(to_process_batch, self.logger) | |||
|
|||
if self.notification_center is not None: |
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.
Should we be validating that notification_center
is an instance of notification_center.NotificationCenter
or does that happen elsewhere?
tests/test_event_processor.py
Outdated
@@ -371,3 +375,29 @@ def test_init__NaN_timeout_interval(self): | |||
# default timeout interval is 5s. | |||
self.assertEqual(self._event_processor.timeout_interval, timedelta(seconds=5)) | |||
mock_config_logging.info.assert_called_with('Using default value for timeout_interval.') | |||
|
|||
def test_notification_center(self): |
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.
nit. test_notification_center__on_log_event
This reverts commit 7d291fe.
Summary
Test plan