Class: Avo::Services::HqReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/avo/services/hq_reporter.rb

Constant Summary collapse

ENDPOINT =
"https://v3.avohq.io/api/v3/licenses/check".freeze
REQUEST_TIMEOUT =

seconds

5
CACHE_TIME =

seconds

24.hours.to_i

Class Method Summary collapse

Class Method Details

.cache_keyObject



11
12
13
# File 'lib/avo/services/hq_reporter.rb', line 11

def cache_key
  "avo.hq_reporter-#{Avo::VERSION.parameterize}.reported"
end

.report(request_info = {}) ⇒ Object

Fire and forget - call this from a thread request_info should be a hash with :ip, :host, :port keys



17
18
19
20
21
22
23
24
25
# File 'lib/avo/services/hq_reporter.rb', line 17

def report(request_info = {})
  return unless should_report?

  cache_store.write(cache_key, {reported_at: Time.now}, expires_in: CACHE_TIME)

  perform_request(request_info)
rescue
  # Silently swallow all errors
end