Class: Exekutor::Queue

Inherits:
Object
  • Object
show all
Defined in:
lib/exekutor/queue.rb

Overview

The job queue

Defined Under Namespace

Classes: Error

Constant Summary collapse

VALID_PRIORITIES =

Valid range for job priority

(1..32_767).freeze
MAX_NAME_LENGTH =

Maximum length for the queue name

63

Instance Method Summary collapse

Instance Method Details

#push(jobs) ⇒ Integer

Adds a job to the queue, scheduled to perform immediately

Parameters:

  • jobs (ActiveJob::Base, Array<ActiveJob::Base>)

    the jobs to enqueue

Returns:

  • (Integer)

    the number of enqueued jobs



22
23
24
# File 'lib/exekutor/queue.rb', line 22

def push(jobs)
  create_records Array.wrap(jobs)
end

#schedule_at(jobs, timestamp) ⇒ Integer

Adds a job to the queue, scheduled to be performed at the indicated time

Parameters:

  • jobs (ActiveJob::Base, Array<ActiveJob::Base>)

    the jobs to enqueue

  • timestamp (Time, Date, Integer, Float)

    when the job should be performed

Returns:

  • (Integer)

    the number of enqueued jobs



30
31
32
# File 'lib/exekutor/queue.rb', line 30

def schedule_at(jobs, timestamp)
  create_records(Array.wrap(jobs), scheduled_at: timestamp)
end