Class: Blazer::RunStatementJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
lib/blazer/run_statement_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(data_source_id, statement, options) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/blazer/run_statement_job.rb', line 5

def perform(data_source_id, statement, options)
  statement = Blazer::Statement.new(statement, data_source_id)
  statement.values = options.delete(:values)
  data_source = statement.data_source
  begin
    ActiveRecord::Base.connection_pool.with_connection do
      Blazer::RunStatement.new.perform(statement, options)
    end
  rescue Exception => e
    Blazer::Result.new(data_source, [], [], "Unknown error", nil, false)
    Blazer.cache.write(data_source.run_cache_key(options[:run_id]), Marshal.dump([[], [], "Unknown error", nil]), expires_in: 30.seconds)
    raise e
  end
end