Module: CronoTrigger::Schedulable::ClassMethods

Defined in:
lib/crono_trigger/schedulable.rb

Instance Method Summary collapse

Instance Method Details

#crono_trigger_column_name(name) ⇒ Object



66
67
68
# File 'lib/crono_trigger/schedulable.rb', line 66

def crono_trigger_column_name(name)
  crono_trigger_options["#{name}_column_name".to_sym].try(:to_s) || name.to_s
end

#executables_with_lock(primary_key_offset: nil, limit: 1000) ⇒ Object



55
56
57
58
59
60
61
62
63
64
# File 'lib/crono_trigger/schedulable.rb', line 55

def executables_with_lock(primary_key_offset: nil, limit: 1000)
  records = nil
  transaction do
    records = executables(primary_key_offset: primary_key_offset, limit: limit).lock.to_a
    unless records.empty?
      where(id: records).update_all(crono_trigger_column_name(:execute_lock) => Time.current.to_i)
    end
    records
  end
end

#execute_lock_timeoutObject



70
71
72
# File 'lib/crono_trigger/schedulable.rb', line 70

def execute_lock_timeout
  (crono_trigger_options[:execute_lock_timeout] || DEFAULT_EXECUTE_LOCK_TIMEOUT)
end