-
Notifications
You must be signed in to change notification settings - Fork 28
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
Conversation
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 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) |
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.
what does it mean respond_to
?
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.
Checks instance method process
exist, similarly we are checking for config_manager; config_manager.respond_to?(:get_config)
lib/optimizely.rb
Outdated
else | ||
ForwardingEventProcessor.new(@event_dispatcher, @logger, @notification_center) | ||
end | ||
# @event_builder = EventBuilder.new(@logger) |
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 it.
lib/optimizely.rb
Outdated
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) |
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.
Please name it log_event
return if @stopped | ||
|
||
@stopped = true | ||
@config_manager.stop! if @config_manager.respond_to?(:stop!) |
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.
how you are making sure, that stop property exists for both event_processor
and config_manager
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 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.
lib/optimizely.rb
Outdated
variation = config.get_variation_from_id(experiment_key, variation_id) | ||
impression_event = EventFactory.create_log_event(user_event, @logger) |
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.
log_event
lib/optimizely.rb
Outdated
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 |
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.
log_event
change will be reflected here.
@@ -85,10 +85,13 @@ def ready? | |||
|
|||
def start! | |||
@async_scheduler.start! |
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.
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 |
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.
what if logger is nil.
return if @stopped | ||
|
||
@stopped = true | ||
@config_manager.stop! if @config_manager.respond_to?(:stop!) |
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 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 |
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.
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) | ||
|
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.
Is the log event notification implemented yet? I think it should be triggered here.
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.
Implemented in PR: #196
Summary
close
in Optimizely class to stopConfigManager
andEventProcessor
Test plan