-
Notifications
You must be signed in to change notification settings - Fork 35
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(event_processor): add forwarding event processor and integrate with optimizely #205
Conversation
Summary ------- - Introduces an EventProcessor interface. - Introduces a BatchEventProcessor Buffering events within a queue before dispatching is an optimization that should prevent SDK implementations from exhausting resources while increasing throughput. This implementation relies on a BlockingCollection to buffer events received from one-to-many producers. A single consumer thread continuously polls from this queue to build a batch before emitting the batched LogEvent. Test plan --------- - Added unit tests.
# Conflicts: # optimizely/event/entity/conversion_event.py # optimizely/event/entity/decision.py # optimizely/event/entity/event_context.py # optimizely/event/entity/impression_event.py
# Conflicts: # optimizely/event/entity/user_event.py # optimizely/event/entity/visitor.py
…into mnoman/AddBatchEP
# Conflicts: # optimizely/event/event_processor.py
…/python-sdk into mnoman/log_event_notification
…vent_processor # Conflicts: # optimizely/event/event_processor.py
optimizely/event/event_processor.py
Outdated
The ForwardingEventProcessor sends the LogEvent to EventDispatcher as soon as it is received. | ||
""" | ||
|
||
def __init__(self, event_dispatcher, logger, 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.
logger
should be optional and we should set it to NoOpLogger
if not provided.
|
||
Args: | ||
event_dispatcher: Provides a dispatch_event method which if given a URL and params sends a request to it. | ||
logger: Optional component which provides a log method to log messages. By default nothing would be logged. |
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.
You say it is optional, but it is not so in practice.
""" | ||
self.event_dispatcher = event_dispatcher | ||
self.logger = logger | ||
self.notification_center = notification_center |
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.
Similar to feedback in #204 shouldn't we validate that notification_center
is an instance of notification_center.NotificationCenter
@@ -43,7 +43,7 @@ class InvalidGroupException(Exception): | |||
|
|||
|
|||
class InvalidInputException(Exception): | |||
""" Raised when provided datafile, event dispatcher, logger or error handler is invalid. """ | |||
""" Raised when provided datafile, event dispatcher, logger, event processor or error handler is invalid. """ |
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. Year in header needs to be updated.
@msohailhussain Have fixed a failing FSC test in this PR.
|
…arding_event_processor
Latest Event Batching Travis Build with Event Batching Testapp Branch https://travis-ci.com/optimizely/fullstack-sdk-compatibility-suite/builds/130617595 |
Should pass once #211 is merged |
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 good. Just need to update the test file.
tests/test_optimizely.py
Outdated
self.assertTrue(isinstance(event, event_builder.Event)) | ||
|
||
# TODO: what should be done about passing dicts of class instances? | ||
# self.assertTrue(isinstance(event, LogEvent)) |
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 is this commented? Can we remove the print statement in the next line?
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.
Done
Summary
Test plan