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

feat(event_processor): add forwarding event processor and integrate with optimizely #205

Merged
merged 126 commits into from
Oct 14, 2019

Conversation

rashidsp
Copy link
Contributor

Summary

  • Add default event processor as forwarding_event_processor.
  • Integrate changes with optimizely.
  • Add validator that ensures that event_processor implements process method.

Test plan

  • Added unit tests.

mjamal@folio3.com and others added 30 commits July 19, 2019 12:16
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
The ForwardingEventProcessor sends the LogEvent to EventDispatcher as soon as it is received.
"""

def __init__(self, event_dispatcher, logger, notification_center=None):
Copy link
Contributor

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.
Copy link
Contributor

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
Copy link
Contributor

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. """
Copy link
Contributor

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.

optimizely/helpers/validator.py Show resolved Hide resolved
@oakbani
Copy link
Contributor

oakbani commented Oct 3, 2019

@msohailhussain Have fixed a failing FSC test in this PR.

  • Now we only wait for 50ms, previously we were waiting for 100ms
  • Now we also allow flush interval in seconds between 0 and 1.

@oakbani oakbani changed the base branch from mnoman/log_event_notification to master October 7, 2019 06:13
@oakbani
Copy link
Contributor

oakbani commented Oct 7, 2019

Latest Event Batching Travis Build with Event Batching Testapp Branch https://travis-ci.com/optimizely/fullstack-sdk-compatibility-suite/builds/130617595

@oakbani oakbani closed this Oct 9, 2019
@oakbani oakbani reopened this Oct 9, 2019
@oakbani
Copy link
Contributor

oakbani commented Oct 9, 2019

Should pass once #211 is merged

Copy link
Contributor

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

self.assertTrue(isinstance(event, event_builder.Event))

# TODO: what should be done about passing dicts of class instances?
# self.assertTrue(isinstance(event, LogEvent))
Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

@mikeproeng37 mikeproeng37 merged commit f57d5bc into master Oct 14, 2019
@oakbani oakbani deleted the rashid/forwarding_event_processor branch October 24, 2019 05:38
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.

None yet

8 participants