class ElasticAPM::Worker

@api private

def initialize(config, queue, adapter)

def initialize(config, queue, adapter)
  @config = config
  @adapter = adapter
  @queue = queue
end

def process(item)

def process(item)
  @adapter.post(item.path, item.payload)
rescue ::Exception => e
  fatal 'Failed posting: %s', e.inspect
  debug e.backtrace.join("\n")
  nil
end

def run_forever

def run_forever
  loop do
    while (item = @queue.pop)
      case item
      when Request
        process item
      when StopMessage
        Thread.exit
      end
    end
  end
end