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

Macro Summary

Instance Method 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 #

def self.metadata_key #

def self.queue #

The Queue this job uses to store job_runs.


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"

Macro Detail

macro after(&block) #

macro before(&block) #

macro queue_name(name) #

Easily override the queue for any job.


Instance Method Detail

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

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

def after_hook #

def before_hook #

def exception : Exception | Nil #

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


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

def executed?(*args, **options, &) #

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.


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

def failed?(*args, **options, &) #

def job_run_id : String | Nil #

def job_run_id=(job_run_id : String | Nil) #

def log(message) #

def metadata : Metadata #

def perform #

abstract, override in a Job descendant to do something productive


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?


def rescheduleable?(retry_count : Int32) : Bool #

abstract, override if desired.

For a given retry count, is this job rescheduleable?


def rescheduleable? : Bool #

abstract, override if desired.

True if this job is rescheduleable, false if not.


def retry_later #

def run #

def should_retry : Bool #

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


def should_retry=(should_retry : Bool) #

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


def state : Mosquito::Job::State #

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

def succeeded?(*args, **options, &) #