class Erorr::Transport::HTTPAsync
Public Class Methods
new()
click to toggle source
# File lib/erorr/transport/http_async.rb, line 9 def initialize @api_key = Erorr.config.api_key @api_url = Erorr.config.api_url end
shut_down()
click to toggle source
# File lib/erorr/transport/http_async.rb, line 19 def shut_down thread_pool.shutdown thread_pool.wait_for_termination end
thread_pool()
click to toggle source
# File lib/erorr/transport/http_async.rb, line 15 def thread_pool @thread_pool ||= Concurrent::ThreadPoolExecutor.new(max_threads: 5) end
Public Instance Methods
deliver(params)
click to toggle source
# File lib/erorr/transport/http_async.rb, line 25 def deliver(params) self.class.thread_pool.post do uri = URI("#{@api_url}/faults") post = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json') post.body = {fault: params, api_key: @api_key}.to_json request = Net::HTTP.new(uri.hostname, uri.port) request.use_ssl = true response = request.start do |http| http.request post end end end