Class: CronoTrigger::Models::Execution

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/crono_trigger/models/execution.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create_with_timestamp!Object



16
17
18
# File 'lib/crono_trigger/models/execution.rb', line 16

def self.create_with_timestamp!
  create!(executed_at: Time.current, status: :executing, worker_id: CronoTrigger.config.worker_id)
end

Instance Method Details

#complete!Object



20
21
22
# File 'lib/crono_trigger/models/execution.rb', line 20

def complete!
  update!(status: :completed, completed_at: Time.current)
end

#error!(exception) ⇒ Object



24
25
26
# File 'lib/crono_trigger/models/execution.rb', line 24

def error!(exception)
  update!(status: :failed, completed_at: Time.current, error_name: exception.class.to_s, error_reason: exception.message)
end

#retry!Object



28
29
30
31
32
# File 'lib/crono_trigger/models/execution.rb', line 28

def retry!
  return false if schedule.locking?

  schedule.retry!
end