module CronoTrigger::Schedulable::ClassMethods

Public Instance Methods

crono_trigger_column_name(name) click to toggle source
# File lib/crono_trigger/schedulable.rb, line 81
def crono_trigger_column_name(name)
  crono_trigger_options["#{name}_column_name".to_sym].try(:to_s) || name.to_s
end
crono_trigger_unlock_all!() click to toggle source
# File lib/crono_trigger/schedulable.rb, line 89
def crono_trigger_unlock_all!
  wheres = all.where_values_hash
  if wheres.empty?
    raise NoRestrictedUnlockError, "Need `where` filter at least one, because this method is danger"
  else
    update_all(
      crono_trigger_column_name(:execute_lock) => 0,
      crono_trigger_column_name(:locked_by) => nil,
    )
  end
end
executables_with_lock(limit: CronoTrigger.config.executor_thread * 3 || 100) click to toggle source
# File lib/crono_trigger/schedulable.rb, line 66
def executables_with_lock(limit: CronoTrigger.config.executor_thread * 3 || 100)
  ids = executables(limit: limit).pluck(:id)
  records = []
  ids.each do |id|
    transaction do
      r = all.lock.find(id)
      unless r.locking?
        r.crono_trigger_lock!
        records << r
      end
    end
  end
  records
end
execute_lock_timeout() click to toggle source
# File lib/crono_trigger/schedulable.rb, line 85
def execute_lock_timeout
  (crono_trigger_options[:execute_lock_timeout] || DEFAULT_EXECUTE_LOCK_TIMEOUT)
end

Private Instance Methods

add_executable_conditions(pr) click to toggle source
# File lib/crono_trigger/schedulable.rb, line 103
def add_executable_conditions(pr)
  self.executable_conditions << pr
end
clear_executable_conditions() click to toggle source
# File lib/crono_trigger/schedulable.rb, line 107
def clear_executable_conditions
  self.executable_conditions.clear
end