class

Mosquito::Job

Inherits Mosquito::Serializers::Primitives < Reference < Object

A Job is a definition for work to be performed. Jobs are pieces of code which run a JobRun.

  • Jobs prevent double execution of a job for a job_run
  • Jobs Rescue when a #perform method fails a job_run for any reason
  • Jobs can be rescheduleable

Constants

Log = ::Log.for(self)

Class methods

metadata
Source
metadata_key
Source
queue

The Queue this job uses to store job_runs.

Source
queue_name

The queue this job is assigned to. By default every job has it's own named queue:

  • EmailTheUniverseJob.queue = "email_the_universe"
Source

Instance methods

aborted?(*args, **options)
Source
aborted?(*args, **options, &)
Source
after_hook
Source
before_hook
Source
exception

When a job fails and raises an exception, it will be saved into this attribute.

Source
executed?(*args, **options)
Source
executed?(*args, **options, &)
Source
fail(reason = "", *, retry : Bool = true)

To be called from inside a #perform Marks this job as a failure. By default, if the job is a candidate for re-scheduling, it will be run again at a later time.

Source
failed?(*args, **options)
Source
failed?(*args, **options, &)
Source
job_run_id
Source
job_run_id=(job_run_id : String | Nil)
Source
log(message)
Source
metadata
Source
perform

abstract, override in a Job descendant to do something productive

Source
reschedule_interval(retry_count : Int32) : Time::Span

abstract, override if desired.

For a given retry count, how long should the delay between job attempts be?

Source
rescheduleable?(retry_count : Int32) : Bool

abstract, override if desired.

For a given retry count, is this job rescheduleable?

Source
rescheduleable?

abstract, override if desired.

True if this job is rescheduleable, false if not.

Source
retry_later
Source
should_retry

When a job run fails, should it be added to the retry queue? See: #fail(retry: false)

Source
should_retry=(should_retry : Bool)

When a job run fails, should it be added to the retry queue? See: #fail(retry: false)

Source
state
Source
succeeded?(*args, **options)
Source
succeeded?(*args, **options, &)
Source

Macros

after
Source
before
Source
queue_name(name)

Easily override the queue for any job.

Source

Nested types