class Mosquito::PeriodicJobRun

Defined in:

mosquito/periodic_job_run.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(class __arg0 : ::Mosquito::PeriodicJob.class, interval : Time::MonthSpan | Time::Span) #

Instance Method Detail

def class : Mosquito::PeriodicJob.class #
Description copied from class Object

Returns the runtime Class of an object.

1.class       # => Int32
"hello".class # => String

Compare it with typeof, which returns the compile-time type of an object:

random_value = rand # => 0.627423
value = random_value < 0.5 ? 1 : "hello"
value         # => "hello"
value.class   # => String
typeof(value) # => Int32 | String

def class=(class __arg0 : Mosquito::PeriodicJob.class) #

def execute #

Enqueues the job for execution


def interval : Time::Span | Time::MonthSpan #

def interval=(interval : Time::Span | Time::MonthSpan) #

def last_executed_at #

The last executed timestamp, or "never" if it doesn't exist.


def last_executed_at=(time : Time) #

Updates the last executed timestamp in the backend, and schedules the metadata for deletion after 3*interval seconds.

For Time::Span intervals, the TTL is set to 3 * interval. For Time::MonthSpan intervals, the TTL is set to approximately 3 * interval.

A month is approximated to 2635200 seconds, or 30.5 days.


def last_executed_at? #

The last executed timestamp for this periodicjob tracked by the backend.


def metadata : Metadata #

def try_to_execute : Bool #

Check the last executed timestamp against the current time, and enqueue the job if it's time to execute.