run_statement_job.rb 657 B

123456789101112131415161718192021
  1. require "sucker_punch"
  2. module Blazer
  3. class RunStatementJob
  4. include SuckerPunch::Job
  5. workers 4
  6. def perform(result, data_source, statement, options)
  7. begin
  8. ActiveRecord::Base.connection_pool.with_connection do
  9. result << Blazer::RunStatement.new.perform(data_source, statement, options)
  10. end
  11. rescue Exception => e
  12. result.clear
  13. result << Blazer::Result.new(data_source, [], [], "Unknown error", nil, false)
  14. Blazer.cache.write(data_source.run_cache_key(options[:run_id]), Marshal.dump([[], [], "Unknown error", nil]), expires_in: 30.seconds)
  15. raise e
  16. end
  17. end
  18. end
  19. end