Class: Marty::PromiseRubyJob
- Inherits:
-
Struct
- Object
- Struct
- Marty::PromiseRubyJob
- Defined in:
- lib/marty/promise_ruby_job.rb
Instance Attribute Summary collapse
-
#hook ⇒ Object
Returns the value of attribute hook.
-
#max_run_time ⇒ Object
Returns the value of attribute max_run_time.
-
#method_args ⇒ Object
Returns the value of attribute method_args.
-
#method_name ⇒ Object
Returns the value of attribute method_name.
-
#module_name ⇒ Object
Returns the value of attribute module_name.
-
#promise ⇒ Object
Returns the value of attribute promise.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
Instance Attribute Details
#hook ⇒ Object
Returns the value of attribute hook
1 2 3 |
# File 'lib/marty/promise_ruby_job.rb', line 1 def hook @hook end |
#max_run_time ⇒ Object
Returns the value of attribute max_run_time
1 2 3 |
# File 'lib/marty/promise_ruby_job.rb', line 1 def max_run_time @max_run_time end |
#method_args ⇒ Object
Returns the value of attribute method_args
1 2 3 |
# File 'lib/marty/promise_ruby_job.rb', line 1 def method_args @method_args end |
#method_name ⇒ Object
Returns the value of attribute method_name
1 2 3 |
# File 'lib/marty/promise_ruby_job.rb', line 1 def method_name @method_name end |
#module_name ⇒ Object
Returns the value of attribute module_name
1 2 3 |
# File 'lib/marty/promise_ruby_job.rb', line 1 def module_name @module_name end |
#promise ⇒ Object
Returns the value of attribute promise
1 2 3 |
# File 'lib/marty/promise_ruby_job.rb', line 1 def promise @promise end |
#title ⇒ Object
Returns the value of attribute title
1 2 3 |
# File 'lib/marty/promise_ruby_job.rb', line 1 def title @title end |
Instance Method Details
#enqueue(job) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/marty/promise_ruby_job.rb', line 10 def enqueue(job) config = Rails.configuration.marty hooks = config.promise_job_enqueue_hooks return if hooks.blank? hooks.each do |hook| hook.call(job) end end |
#max_attempts ⇒ Object
55 56 57 |
# File 'lib/marty/promise_ruby_job.rb', line 55 def max_attempts 1 end |
#perform ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/marty/promise_ruby_job.rb', line 21 def perform promise.set_start begin Mcfly.whodunnit = promise.user ENV['__promise_id'] = promise.id.to_s mod = module_name.constantize res = { 'result' => mod.send(method_name, *method_args) } rescue ::Delayed::WorkerTimeout => e msg = ::Marty::Promise.(promise) timeout_error = StandardError.new( "#{msg} (Triggered by #{e.class})" ) timeout_error.set_backtrace(e.backtrace) res = Delorean::Engine.grok_runtime_exception(timeout_error) rescue StandardError => e res = ::Marty::Promise.exception_to_result(promise: promise, exception: e) end promise.set_result(res) process_hook(res) ENV.delete('__promise_id') end |