Class: Resque::Stagger::Staggered

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

Overview

The Staggered class is used to enqueue jobs with a stagger effect.

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Staggered

Initializes the Staggered class with given options.

Parameters:

  • options (Hash)

    the options for the stagger effect.

Options Hash (**options):

  • :start_from (Time)

    starting time for enqueuing jobs.

  • :per_second (Integer)

    number of jobs to enqueue per second.



13
14
15
# File 'lib/resque/stagger.rb', line 13

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

Instance Method Details

#enqueue(klass, *args) ⇒ Object

Enqueues the given job with a stagger effect.

Parameters:

  • klass (Class)

    the job class to be enqueued.

  • args (Array)

    the arguments for the job.



21
22
23
# File 'lib/resque/stagger.rb', line 21

def enqueue(klass, *args)
  ::Resque.enqueue_at(current_enqueue_at, klass, *args)
end