Module: CronoTrigger::Schedulable::ClassMethods
- Defined in:
- lib/crono_trigger/schedulable.rb
Instance Method Summary collapse
- #crono_trigger_column_name(name) ⇒ Object
- #executables_with_lock(primary_key_offset: nil, limit: 1000) ⇒ Object
- #execute_lock_timeout ⇒ Object
Instance Method Details
#crono_trigger_column_name(name) ⇒ Object
64 65 66 |
# File 'lib/crono_trigger/schedulable.rb', line 64 def crono_trigger_column_name(name) ["#{name}_column_name".to_sym].try(:to_s) || name.to_s end |
#executables_with_lock(primary_key_offset: nil, limit: 1000) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/crono_trigger/schedulable.rb', line 53 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_timeout ⇒ Object
68 69 70 |
# File 'lib/crono_trigger/schedulable.rb', line 68 def execute_lock_timeout ([:execute_lock_timeout] || DEFAULT_EXECUTE_LOCK_TIMEOUT) end |