Skip to content

feat(integrateep): Integrate Event processor #194

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

Merged
merged 36 commits into from
Aug 28, 2019

Conversation

msohailhussain
Copy link
Contributor

@msohailhussain msohailhussain commented Aug 8, 2019

Summary

  • Integrated Event Processor with Optimizely class
  • Added close in Optimizely class to stop ConfigManager and EventProcessor
  • Default ForwardingEventProcessor is implemented and used while not providing EP

Test plan

  • Added Unit tests
  • Need to test with FSC.

@coveralls
Copy link

coveralls commented Aug 8, 2019

Coverage Status

Coverage increased (+0.07%) to 99.435% when pulling e802860 on rashid/optly-EP-integration into c6a2bfe on master.

Copy link
Contributor Author

@msohailhussain msohailhussain left a comment

Choose a reason for hiding this comment

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

I don't see any unit tests updated for optimizely_spec. Please check Integration PR in C#, we have to make sure when any Optimizely Activate or Track is called, then the expected impression or conversion event type should be asserted.

@@ -92,7 +95,13 @@ def initialize(
StaticProjectConfigManager.new(datafile, @logger, @error_handler, skip_json_validation)
end
@decision_service = DecisionService.new(@logger, @user_profile_service)
@event_builder = EventBuilder.new(@logger)

@event_processor = if event_processor.respond_to?(:process)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

what does it mean respond_to ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Checks instance method process exist, similarly we are checking for config_manager; config_manager.respond_to?(:get_config)

else
ForwardingEventProcessor.new(@event_dispatcher, @logger, @notification_center)
end
# @event_builder = EventBuilder.new(@logger)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove it.

event_key, user_id, attributes, event_tags, conversion_event
)
if @notification_center.notification_count(NotificationCenter::NOTIFICATION_TYPES[:TRACK]).positive?
conversion_event = EventFactory.create_log_event(user_event, @logger)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please name it log_event

return if @stopped

@stopped = true
@config_manager.stop! if @config_manager.respond_to?(:stop!)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

how you are making sure, that stop property exists for both event_processor and config_manager

Copy link

Choose a reason for hiding this comment

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

I suggest stop should be treated as required for any event_processor or config_manager passed in. We could validate them in the constructor. When stop doesn't exist, we can log a message and ignore it.

variation = config.get_variation_from_id(experiment_key, variation_id)
impression_event = EventFactory.create_log_event(user_event, @logger)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

log_event

variation = config.get_variation_from_id(experiment_key, variation_id)
impression_event = EventFactory.create_log_event(user_event, @logger)
@notification_center.send_notifications(
NotificationCenter::NOTIFICATION_TYPES[:ACTIVATE],
experiment, user_id, attributes, variation, impression_event
Copy link
Contributor Author

Choose a reason for hiding this comment

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

log_event change will be reflected here.

@@ -85,10 +85,13 @@ def ready?

def start!
@async_scheduler.start!
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Must check if it is stopped, then no need to start again.

# the event batch into a LogEvent to be dispatched.
def initialize(event_dispatcher, logger, notification_center = nil)
@event_dispatcher = event_dispatcher
@logger = logger
Copy link
Contributor Author

Choose a reason for hiding this comment

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

what if logger is nil.

@msohailhussain msohailhussain requested a review from a team as a code owner August 18, 2019 15:08
@msohailhussain msohailhussain changed the title feat(integrateep): Integrate Event processor - WIP feat(integrateep): Integrate Event processor Aug 20, 2019
@rashidsp rashidsp changed the base branch from rashid/batch-event-processor to master August 23, 2019 08:23
return if @stopped

@stopped = true
@config_manager.stop! if @config_manager.respond_to?(:stop!)
Copy link

Choose a reason for hiding this comment

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

I suggest stop should be treated as required for any event_processor or config_manager passed in. We could validate them in the constructor. When stop doesn't exist, we can log a message and ignore it.

@@ -102,7 +102,7 @@ def stop!
@received.signal
end

@is_started = false
@started = false
Copy link

Choose a reason for hiding this comment

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

What if stop! is called several times quickly? Would it be more correct this way, with checking @started first?

def stop!
  return unless @started
  return unless @thread.alive? # not sure if this is still necessary?
  
  @logger.log(Logger::WARN, 'Stopping scheduler.')
  @started = false
  @mutex.synchronize do
    event_queue << SHUTDOWN_SIGNAL
    @received.signal
  end

  @thread.exit
end


def process(user_event)
log_event = Optimizely::EventFactory.create_log_event(user_event, @logger)

Copy link

Choose a reason for hiding this comment

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

Is the log event notification implemented yet? I think it should be triggered here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Implemented in PR: #196

@mikeproeng37 mikeproeng37 merged commit 2df63ad into master Aug 28, 2019
@rashidsp rashidsp deleted the rashid/optly-EP-integration branch August 29, 2019 19:11
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.

6 participants