Module: Rekiq::Worker::ClassMethods

Defined in:
lib/rekiq/worker.rb

Instance Method Summary collapse

Instance Method Details

#perform_recurringly(schedule, *args) {|config| ... } ⇒ Object Also known as: perform_schedule

Yields:

  • (config)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# 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