class Opbeat::Worker
@api private
Attributes
config[R]
Public Class Methods
new(config, queue, http_client)
click to toggle source
# File lib/opbeat/worker.rb, line 15 def initialize config, queue, http_client @config = config @queue = queue @http_client = http_client end
Public Instance Methods
run()
click to toggle source
# File lib/opbeat/worker.rb, line 23 def run loop do while action = @queue.pop case action when PostRequest process_request action when StopMessage Thread.exit else raise Error.new("Unknown entity in worker queue: #{action.inspect}") end end end end
Private Instance Methods
process_request(req)
click to toggle source
# File lib/opbeat/worker.rb, line 40 def process_request req unless config.validate! info "Invalid config - Skipping posting to Opbeat" return end begin @http_client.post(req.path, req.data) rescue => e fatal "Failed POST: #{e.inspect}" debug e.backtrace.join("\n") end end