Skip to content

Commit

Permalink
Merge pull request #168 from segmentio/rohitpaulk/revert-tcp-conn-reuse
Browse files Browse the repository at this point in the history
Revert "Reuse TCP connections"
  • Loading branch information
f2prateek committed Jun 25, 2018
2 parents efbb754 + 494b3ff commit 244e1ad
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
5 changes: 0 additions & 5 deletions lib/segment/analytics/request.rb
Expand Up @@ -117,11 +117,6 @@ def send_request(write_key, batch)

[200, '{}']
else
# If `start` is not called, Ruby adds a 'Connection: close' header to
# all requests, preventing us from reusing a connection for multiple
# HTTP requests
@http.start unless @http.started?

response = @http.request(request, payload)
[response.code.to_i, response.body]
end
Expand Down
4 changes: 2 additions & 2 deletions lib/segment/analytics/worker.rb
Expand Up @@ -29,7 +29,6 @@ def initialize(queue, write_key, options = {})
batch_size = options[:batch_size] || Defaults::MessageBatch::MAX_SIZE
@batch = MessageBatch.new(batch_size)
@lock = Mutex.new
@request = Request.new
end

# public: Continuously runs the loop to check for new events
Expand All @@ -42,7 +41,8 @@ def run
@batch << @queue.pop until @batch.full? || @queue.empty?
end

res = @request.post(@write_key, @batch)
res = Request.new.post @write_key, @batch

@on_error.call(res.status, res.error) unless res.status == 200

@lock.synchronize { @batch.clear }
Expand Down

0 comments on commit 244e1ad

Please sign in to comment.