Class: Chicago::ETL::TaskInvocation
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- Chicago::ETL::TaskInvocation
- Defined in:
- lib/chicago/etl/task_invocation.rb
Instance Method Summary collapse
-
#finished? ⇒ Boolean
Returns true if this task has finished running successfully.
-
#perform ⇒ Object
Executes a block of code.
Instance Method Details
#finished? ⇒ Boolean
Returns true if this task has finished running successfully.
25 26 27 |
# File 'lib/chicago/etl/task_invocation.rb', line 25 def finished? state == "Finished" end |
#perform ⇒ Object
Executes a block of code.
Sets the state to “Error” and re-raises any exception that the block of code raises.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/chicago/etl/task_invocation.rb', line 11 def perform raise RuntimeError.new("The task #{name} in batch #{batch_id} has already run") if finished? update(:state => "Started", :attempts => attempts + 1) begin yield rescue Exception => e update(:state => "Error") batch.error if batch raise e end update(:state => "Finished", :finished_at => Time.now) end |