Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Metrics/AbcSize:
# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 223
Max: 229

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I tried to reduce this by using common fields, but found a few places where we seem to be off-spec. Will do this in a separate PR.


# Offense count: 1
Metrics/CyclomaticComplexity:
Expand Down
12 changes: 10 additions & 2 deletions lib/segment/analytics/client.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
require 'thread'
require 'time'

require 'segment/analytics/defaults'
require 'segment/analytics/logging'
require 'segment/analytics/utils'
require 'segment/analytics/worker'
require 'segment/analytics/defaults'

module Segment
class Analytics
class Client
include Segment::Analytics::Utils
include Segment::Analytics::Logging

# public: Creates a new client
#
Expand Down Expand Up @@ -314,7 +317,12 @@ def enqueue(action)

true
else
false # Queue is full
logger.warn(
'Queue is full, dropping events. The :max_queue_size ' \
'configuration parameter can be increased to prevent this from ' \
'happening.'
)
false
end
end

Expand Down
10 changes: 10 additions & 0 deletions spec/segment/analytics/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,16 @@ class Analytics
end
end

it 'returns false if queue is full' do
client.instance_variable_set(:@max_queue_size, 1)

[:track, :screen, :page, :group, :identify, :alias].each do |s|
expect(client.send(s, data)).to eq(true)
expect(client.send(s, data)).to eq(false) # Queue is full
queue.pop(true)
end
end

it 'converts message id to string' do
[:track, :screen, :page, :group, :identify, :alias].each do |s|
client.send(s, data)
Expand Down