8000 refact: Batch Event Processor and Unit Tests by oakbani · Pull Request #215 · optimizely/ruby-sdk · GitHub
[go: up one dir, main page]

Skip to content

refact: Batch Event Processor and Unit Tests #215

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 8 commits into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Added log
  • Loading branch information
oakbani committed Oct 29, 2019
commit 6f4467895686d2e0d92920ca60c7949e0f108c9d
7 changes: 6 additions & 1 deletion lib/optimizely/event/batch_event_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ def flush_queue!

log_event = Optimizely::EventFactory.create_log_event(@current_batch, @logger)
begin
@logger.log(
Logger::INFO,
'Flushing Queue.'
)

@event_dispatcher.dispatch_event(log_event)
@notification_center&.send_notifications(
NotificationCenter::NOTIFICATION_TYPES[:LOG_EVENT],
Expand All @@ -171,7 +176,7 @@ def add_to_batch(user_event)
@current_batch << user_event
return unless @current_batch.length >= @batch_size

@logger.log(Logger::DEBUG, 'Flushing on max batch size!')
@logger.log(Logger::DEBUG, 'Flushing on max batch size.')
flush_queue!
end

Expand Down
3 changes: 2 additions & 1 deletion spec/event/batch_event_processor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
Optimizely::NotificationCenter::NOTIFICATION_TYPES[:LOG_EVENT],
log_event
).once
expect(spy_logger).to have_received(:log).with(Logger::INFO, 'Flushing Queue.').once
end

it 'should flush the current batch when max batch size met' do
Expand Down Expand Up @@ -98,7 +99,7 @@
expect(@event_dispatcher).to have_received(:dispatch_event).with(
Optimizely::EventFactory.create_log_event(expected_batch, spy_logger)
).once
expect(spy_logger).to have_received(:log).with(Logger::DEBUG, 'Flushing on max batch size!').once
expect(spy_logger).to have_received(:log).with(Logger::DEBUG, 'Flushing on max batch size.').once
end

it 'should dispatch the event when flush is called' do
Expand Down
0