Class: Resque::Staggered

Inherits:
Object
  • Object
show all
Defined in:
lib/resque/staggered.rb

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Staggered

Initializes a new Staggered object.

Parameters:

  • options (Hash)

    The options to create the Staggered object with.

Options Hash (**options):

  • :start_from (Time)

    The time to start enqueueing jobs from (defaults to Time.current).

  • :number_of_jobs (Integer)

    The number of jobs to enqueue per unit time.

  • :unit_time_in_seconds (Integer)

    The time interval between each set of jobs.

  • :queue (String)

    The name of the queue to enqueue the jobs in (optional).



14
15
16
# File 'lib/resque/staggered.rb', line 14

def initialize(**options)
  @options = options
end

Instance Method Details

#enqueue(klass, *args) ⇒ void

This method returns an undefined value.

Enqueues a job with the given arguments at a staggered time.

Parameters:

  • klass (Object)

    The job class to enqueue.

  • args (Array)

    The arguments to pass to the job.



24
25
26
27
28
29
30
# File 'lib/resque/staggered.rb', line 24

def enqueue(klass, *args)
  if queue.present?
    ::Resque.enqueue_at_with_queue(queue, current_enqueue_at, klass, *args)
  else
    ::Resque.enqueue_at(current_enqueue_at, klass, *args)
  end
end