Class: Marty::PromiseJob
- Inherits:
-
Struct
- Object
- Struct
- Marty::PromiseJob
- Defined in:
- lib/marty/promise_job.rb
Instance Attribute Summary collapse
-
#attrs ⇒ Object
Returns the value of attribute attrs.
-
#hook ⇒ Object
Returns the value of attribute hook.
-
#node ⇒ Object
Returns the value of attribute node.
-
#params ⇒ Object
Returns the value of attribute params.
-
#promise ⇒ Object
Returns the value of attribute promise.
-
#sname ⇒ Object
Returns the value of attribute sname.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #max_attempts ⇒ Object
-
#perform ⇒ Object
def log(msg) open(‘/tmp/dj.out’, ‘a’) { |f| f.puts msg } end.
Instance Attribute Details
#attrs ⇒ Object
Returns the value of attribute attrs
92 93 94 |
# File 'lib/marty/promise_job.rb', line 92 def attrs @attrs end |
#hook ⇒ Object
Returns the value of attribute hook
92 93 94 |
# File 'lib/marty/promise_job.rb', line 92 def hook @hook end |
#node ⇒ Object
Returns the value of attribute node
92 93 94 |
# File 'lib/marty/promise_job.rb', line 92 def node @node end |
#params ⇒ Object
Returns the value of attribute params
92 93 94 |
# File 'lib/marty/promise_job.rb', line 92 def params @params end |
#promise ⇒ Object
Returns the value of attribute promise
92 93 94 |
# File 'lib/marty/promise_job.rb', line 92 def promise @promise end |
#sname ⇒ Object
Returns the value of attribute sname
92 93 94 |
# File 'lib/marty/promise_job.rb', line 92 def sname @sname end |
#tag ⇒ Object
Returns the value of attribute tag
92 93 94 |
# File 'lib/marty/promise_job.rb', line 92 def tag @tag end |
#title ⇒ Object
Returns the value of attribute title
92 93 94 |
# File 'lib/marty/promise_job.rb', line 92 def title @title end |
Instance Method Details
#max_attempts ⇒ Object
135 136 137 |
# File 'lib/marty/promise_job.rb', line 135 def max_attempts 1 end |
#perform ⇒ Object
def log(msg)
open('/tmp/dj.out', 'a') { |f| f.puts msg }
end
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/marty/promise_job.rb', line 105 def perform # log "PERF #{Process.pid} #{title}" promise.set_start begin # in case the job writes to the the database Mcfly.whodunnit = promise.user engine = Marty::ScriptSet.new(tag).get_engine(sname) attrs_eval = engine.evaluate(node, attrs, params) res = attrs.zip(attrs_eval).each_with_object({}) do |(attr, val), h| h[attr] = val end # log "DONE #{Process.pid} #{promise.id} #{Time.now.to_f} #{res}" rescue => exc res = Delorean::Engine.grok_runtime_exception(exc) # log "ERR- #{Process.pid} #{promise.id} #{Time.now.to_f} #{exc}" end promise.set_result(res) begin hook.run(res) if hook rescue => exc Marty::Util.logger.error "promise hook failed: #{exc}" end end |