class PostHog::SendWorker
def initialize(queue, api_key, options = {})
on_error - Proc of what to do on an error
batch_size - Fixnum of how many items to send in a batch
options - Hash of worker options
api_key - String of the project's API key
queue - Queue synchronized between client and worker
and makes requests to the posthog.com api
The worker continuously takes messages off the queue
public: Creates a new worker
def initialize(queue, api_key, options = {}) symbolize_keys! options @queue = queue @api_key = api_key @on_error = options[:on_error] || proc { |status, error| } batch_size = options[:batch_size] || Defaults::MessageBatch::MAX_SIZE @batch = MessageBatch.new(batch_size) @lock = Mutex.new @transport = Transport.new api_host: options[:host], skip_ssl_verification: options[:skip_ssl_verification] end