module JoobQ::Job

Overview

The JoobQ::Job module provides an abstract structure for defining jobs within the JoobQ asynchronous job processing framework. This module includes functionality for managing job statuses, scheduling, retries, timeouts, and more.

Example Usage

To define a custom job, include the JoobQ::Job module within your job class and implement the #perform method.

class ExampleJob
  include JoobQ::Job

  def perform
    puts "Executing job logic"
  end
end

You can then enqueue, delay, or schedule the job using provided methods.

Job Status

The JoobQ::Job::Status enum defines the possible states for a job:

Each status has corresponding predicate and setter methods for checking and updating job status.

Properties

Methods

Status Predicate and Setter Methods

The module automatically defines predicate and setter methods for each job status:

job = ExampleJob.new
job.running! # Sets the job's status to Running
job.running? # Checks if the job's status is Running

Enqueue and Execution Methods

ExampleJob.batch_enqueue([job1, job2, job3])
ExampleJob.enqueue(param: "value")
ExampleJob.perform(param: "value")

Delay and Scheduling

ExampleJob.enqueue_at(1.minute, param: "value")
ExampleJob.delay(2.minutes, param: "value")
ExampleJob.schedule(5.seconds, param: "value")

Defined in:

joobq/job.cr

Instance Method Summary

Instance Method Detail

def <=>(other) #

[View source]
abstract def perform #

[View source]