Sha256: a1ed7a3c0d8e8cabd9821a8c273f5031b7964952843c3630ace2b09587ef9325
Contents?: true
Size: 934 Bytes
Versions: 1
Compression:
Stored size: 934 Bytes
Contents
require 'net/http' require 'net/https' require 'uri' require 'concurrent' module Nadir module Transport class HTTPAsync def initialize @api_key = Nadir.config.api_key @api_url = Nadir.config.api_url end class << self def thread_pool @thread_pool ||= Concurrent::ThreadPoolExecutor.new(max_threads: 5) end def shut_down thread_pool.shutdown thread_pool.wait_for_termination end end def deliver(params) self.class.thread_pool.post do uri = URI("#{@api_url}/faults") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true if uri.class == URI::HTTPS request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json') request.body = {fault: params, api_key: @api_key}.to_json http.request request end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nadir-1.0.2 | lib/nadir/transport/http_async.rb |