Class: Httrace::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/httrace.rb

Overview

── Client ─────────────────────────────────────────────────────────────────

Constant Summary collapse

BATCH_SIZE =
50
MAX_QUEUE =
10_000

Instance Method Summary collapse

Constructor Details

#initialize(api_key, endpoint) ⇒ Client

Returns a new instance of Client.



165
166
167
168
169
170
171
172
# File 'lib/httrace.rb', line 165

def initialize(api_key, endpoint)
  @api_key  = api_key
  @uri      = URI.parse(endpoint)
  @queue    = []
  @mu       = Mutex.new
  @worker   = Thread.new { run_worker }
  @worker.abort_on_exception = false
end

Instance Method Details

#enqueue(interaction) ⇒ Object



174
175
176
177
178
# File 'lib/httrace.rb', line 174

def enqueue(interaction)
  @mu.synchronize do
    @queue << interaction if @queue.size < MAX_QUEUE
  end
end