Skip to content

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.

@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.


@logger.log(Logger::INFO, "Activating user '#{user_id}' in experiment '#{experiment_key}'.")
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

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.

end

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.

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.

7 participants