Sha256: 7dfe560da596a966d7ef6e740da319a34ad22cc54975c955442a7252188307e9

Contents?: true

Size: 669 Bytes

Versions: 4

Compression:

Stored size: 669 Bytes

Contents

require 'json'
require 'faraday'
require 'getaround_utils/utils/async_queue'

class GetaroundUtils::Utils::HttpReporter
  class AsyncQueue < GetaroundUtils::Utils::AsyncQueue
    def self.perform(url:, params: {}, headers: {}, body: nil)
      Faraday.post(url) do |req|
        req.options[:open_timeout] = 1
        req.options[:timeout] = 1
        req.params = params
        req.headers = headers
        req.body = body
      end
    end
  end

  def initialize(url:)
    @url = url
  end

  def report(event)
    AsyncQueue.perform_async(
      url: @url,
      headers: { 'Content-Type' => 'application/json' },
      body: JSON.generate(event)
    )
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
getaround_utils-0.1.19 lib/getaround_utils/utils/http_reporter.rb
getaround_utils-0.1.18 lib/getaround_utils/utils/http_reporter.rb
getaround_utils-0.1.17 lib/getaround_utils/utils/http_reporter.rb
getaround_utils-0.1.15 lib/getaround_utils/utils/http_reporter.rb