Class: ThreeScale::Backend::Transactor::ReportJob

Inherits:
BackgroundJob
  • Object
show all
Defined in:
lib/3scale/backend/transactor/report_job.rb

Overview

Job for reporting transactions.

Constant Summary

Constants inherited from BackgroundJob

BackgroundJob::EMPTY_HOOKS, BackgroundJob::Error

Class Method Summary collapse

Methods inherited from BackgroundJob

hooks, perform

Methods included from Configurable

#configuration, #configuration=, included

Class Method Details

.perform_logged(service_id, raw_transactions, _enqueue_time, context_info = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/3scale/backend/transactor/report_job.rb', line 10

def perform_logged(service_id, raw_transactions, _enqueue_time, context_info = {})
  context_info ||= {} # avoid nils potentially existing in older versions
  request_info = context_info['request'.freeze] || {}

  transactions = parse_transactions(service_id, raw_transactions, request_info)
  ProcessJob.perform(transactions) if !transactions.nil? && transactions.size > 0

  # Last field was logs.size. Set it to 0 until we modify our parsers.
  [true, "#{service_id} #{transactions.size} 0"]
rescue Error => error
  ErrorStorage.store(service_id, error, context_info)
  [false, "#{service_id} #{error}"]
rescue Exception => error
  if error.class == ArgumentError &&
      error.message == "invalid byte sequence in UTF-8"

    ErrorStorage.store(service_id, NotValidData.new, context_info)
    [false, "#{service_id} #{error}"]
  else
    raise error
  end
end