Sha256: 6ee742cbdf8cc7206ba8842ca3d3ebed3ecb93f145f434b4c2252a7b58d47afd
Contents?: true
Size: 838 Bytes
Versions: 5
Compression:
Stored size: 838 Bytes
Contents
module Chicago module ETL class TaskInvocation < Sequel::Model set_dataset :etl_task_invocations many_to_one :batch # Executes a block of code. # # Sets the state to "Error" and re-raises any exception that the # block of code raises. 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 # Returns true if this task has finished running successfully. def finished? state == "Finished" end end end end
Version data entries
5 entries across 5 versions & 1 rubygems