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



18
19
20
# File 'lib/crono_trigger/models/execution.rb', line 18

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

Instance Method Details

#complete!Object



22
23
24
# File 'lib/crono_trigger/models/execution.rb', line 22

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

#error!(exception) ⇒ Object



26
27
28
# File 'lib/crono_trigger/models/execution.rb', line 26

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

#retry!Object



30
31
32
33
34
# File 'lib/crono_trigger/models/execution.rb', line 30

def retry!
  return false if schedule.locking?

  schedule.retry!
end