abstract class Mosquito::Job

Overview

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

Included Modules

Direct Known Subclasses

Defined in:

mosquito/job.cr

Constant Summary

Log = ::Log.for(self)

Class Method Summary

Instance Method Summary

Macro Summary

Instance methods inherited from module Mosquito::Serializers::Primitives

deserialize_bool(raw : String) : Bool deserialize_bool, deserialize_char(raw : String) : Char deserialize_char, deserialize_float32(raw : String) : Float32 | Nil deserialize_float32, deserialize_float64(raw : String) : Float64 | Nil deserialize_float64, deserialize_int128(raw : String) : Int128 | Nil deserialize_int128, deserialize_int16(raw : String) : Int16 | Nil deserialize_int16, deserialize_int32(raw : String) : Int32 | Nil deserialize_int32, deserialize_int64(raw : String) : Int64 | Nil deserialize_int64, deserialize_int8(raw : String) : Int8 | Nil deserialize_int8, deserialize_string(raw : String) : String deserialize_string, deserialize_u_int128(raw : String) : UInt128 | Nil deserialize_u_int128, deserialize_u_int16(raw : String) : UInt16 | Nil deserialize_u_int16, deserialize_u_int32(raw : String) : UInt32 | Nil deserialize_u_int32, deserialize_u_int64(raw : String) : UInt64 | Nil deserialize_u_int64, deserialize_u_int8(raw : String) : UInt8 | Nil deserialize_u_int8, deserialize_uuid(raw : String) : UUID deserialize_uuid, serialize_bool(value : Bool) : String serialize_bool, serialize_char(char : Char) : String serialize_char, serialize_float32(value) : String serialize_float32, serialize_float64(value) : String serialize_float64, serialize_int128(value) : String serialize_int128, serialize_int16(value) : String serialize_int16, serialize_int32(value) : String serialize_int32, serialize_int64(value) : String serialize_int64, serialize_int8(value) : String serialize_int8, serialize_string(str : String) : String serialize_string, serialize_symbol(sym : Symbol) : Nil serialize_symbol, serialize_u_int128(value) : String serialize_u_int128, serialize_u_int16(value) : String serialize_u_int16, serialize_u_int32(value) : String serialize_u_int32, serialize_u_int64(value) : String serialize_u_int64, serialize_u_int8(value) : String serialize_u_int8, serialize_uuid(uuid : UUID) : String serialize_uuid

Class Method Detail

def self.metadata : Metadata #

[View source]
def self.metadata_key #

[View source]
def self.queue #

The Queue this job uses to store job_runs.


[View source]
def self.queue_name : String #

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

  • EmailTheUniverseJob.queue = "email_the_universe"

[View source]

Instance Method Detail

def aborted?(*args, **options) #

[View source]
def aborted?(*args, **options, &) #

[View source]
def after_hook #

[View source]
def before_hook #

[View source]
def exception : Exception | Nil #

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


[View source]
def executed?(*args, **options) #

[View source]
def executed?(*args, **options, &) #

[View source]
def 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.


[View source]
def failed?(*args, **options) #

[View source]
def failed?(*args, **options, &) #

[View source]
def job_run_id : String | Nil #

[View source]
def job_run_id=(job_run_id : String | Nil) #

[View source]
def log(message) #

[View source]
def metadata : Metadata #

[View source]
def perform #

abstract, override in a Job descendant to do something productive


[View source]
def 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?


[View source]
def rescheduleable?(retry_count : Int32) : Bool #

abstract, override if desired.

For a given retry count, is this job rescheduleable?


[View source]
def rescheduleable? : Bool #

abstract, override if desired.

True if this job is rescheduleable, false if not.


[View source]
def retry_later #

[View source]
def run #

[View source]
def should_retry : Bool #

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


[View source]
def should_retry=(should_retry : Bool) #

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


[View source]
def state : Mosquito::Job::State #

[View source]
def succeeded?(*args, **options) #

[View source]
def succeeded?(*args, **options, &) #

[View source]

Macro Detail

macro after(&block) #

[View source]
macro before(&block) #

[View source]
macro queue_name(name) #

Easily override the queue for any job.


[View source]