Method: Clearbit::Analytics::Client#initialize

Defined in:
lib/clearbit/analytics/client.rb

#initialize(opts = {}) ⇒ Client

Returns a new instance of Client.

Parameters:

  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :write_key (String)

    Your project's write_key

  • :max_queue_size (FixNum)

    Maximum number of calls to be remain queued.

  • :on_error (Proc)

    Handles error calls from the API.



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/clearbit/analytics/client.rb', line 20

def initialize(opts = {})
  symbolize_keys!(opts)

  @queue = Queue.new
  @write_key = opts[:write_key]
  @max_queue_size = opts[:max_queue_size] || Defaults::Queue::MAX_SIZE
  @worker_mutex = Mutex.new
  @worker = Worker.new(@queue, @write_key, opts)

  check_write_key!

  at_exit { @worker_thread && @worker_thread[:should_exit] = true }
end