Class: ActiveWorker::JobQueue::JobExecuter
- Inherits:
-
Object
- Object
- ActiveWorker::JobQueue::JobExecuter
- Defined in:
- lib/active_worker/job_queue/job_executer.rb
Class Method Summary collapse
- .execute_task_from_args(args) ⇒ Object
- .handle_exception(e, method, params, klass) ⇒ Object
- .handle_termination(klass, params, exception = nil) ⇒ Object
- .log_error(message) ⇒ Object
- .perform(args) ⇒ Object
Class Method Details
.execute_task_from_args(args) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/active_worker/job_queue/job_executer.rb', line 15 def self.execute_task_from_args(args) class_name = args["class_name"] method = args["method"] params = args["params"] klass = class_name.constantize klass.send(method,*params) rescue Resque::TermException => e handle_termination(klass, params, e) rescue SignalException => e handle_exception(e, method, params, klass) raise e rescue Exception => e handle_exception(e, method, params, klass) end |
.handle_exception(e, method, params, klass) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/active_worker/job_queue/job_executer.rb', line 32 def self.handle_exception(e, method, params, klass) log_error "Handling exception for #{klass} because #{e.}" klass.handle_error e, method, params rescue Exception => handle_error_error log_error "Handle error exception: #{handle_error_error.}" log_error handle_error_error.backtrace.join("\n") end |
.handle_termination(klass, params, exception = nil) ⇒ Object
40 41 42 43 44 |
# File 'lib/active_worker/job_queue/job_executer.rb', line 40 def self.handle_termination(klass, params, exception = nil) log_error "Handling #{exception || "termination" } for #{klass}" klass.handle_termination params exit end |
.log_error(message) ⇒ Object
46 47 48 |
# File 'lib/active_worker/job_queue/job_executer.rb', line 46 def self.log_error() puts "JOB EXECUTOR: #{}" end |
.perform(args) ⇒ Object
11 12 13 |
# File 'lib/active_worker/job_queue/job_executer.rb', line 11 def self.perform(args) execute_task_from_args(args) end |