module Rekiq::Worker::ClassMethods

Public Instance Methods

perform_recurringly(schedule, *args) { |config| ... } click to toggle source
# File lib/rekiq/worker.rb, line 17
def perform_recurringly(schedule, *args)
  validate!

  config = Configuration.new
  yield config if block_given?

  contract =
    Rekiq::Contract
      .new 'schedule'            => schedule,
           'cancel_args'         => config.cancel_args,
           'addon'               => config.addon,
           'schedule_post_work'  => config.schedule_post_work,
           'work_time_shift'     => config.work_time_shift,
           'work_time_tolerance' => config.work_time_tolerance,
           'schedule_expired'    => config.schedule_expired

  contract.validate!

  queue = get_sidekiq_options['queue']

  jid, work_time =
    Rekiq::Scheduler
      .new(self.name, queue, args, contract)
      .schedule_initial_work(config.starting_at || Time.now)

  unless jid.nil?
    ::Sidekiq.logger.info \
      "recurring work for #{self.name} scheduled for #{work_time} " \
      "with jid #{jid}"
  end

  jid
end
Also aliased as: perform_schedule
perform_schedule(schedule, *args)
Alias for: perform_recurringly

Protected Instance Methods

validate!() click to toggle source
# File lib/rekiq/worker.rb, line 54
def validate!
  method_name = get_sidekiq_options['rekiq_cancel_method']

  unless method_name.nil? or method_defined?(method_name)
    raise ::Rekiq::CancelMethodMissing,
          "rekiq cancel method name defined as #{method_name}, but " \
          'worker has no method with that name, either remove '      \
          'definition or define missing method'
  end
end