class
Mosquito::PeriodicJobRun
- Mosquito::PeriodicJobRun
- Reference
- Object
Defined in:
mosquito/periodic_job_run.crConstant Summary
-
Log =
::Log.for(self)
Constructors
Instance Method Summary
-
#class : Mosquito::PeriodicJob.class
Returns the runtime
Classof an object. - #class=(class __arg0 : Mosquito::PeriodicJob.class)
-
#execute
Enqueues the job for execution and records the job run id so that subsequent intervals can detect that a run is already pending.
- #interval : Time::Span | Time::MonthSpan
- #interval=(interval : Time::Span | Time::MonthSpan)
-
#last_executed_at
The last executed timestamp, or "never" if it doesn't exist.
-
#last_executed_at=(time : Time)
Updates the last executed timestamp in the backend, and schedules the metadata for deletion after 3*interval seconds.
-
#last_executed_at?
The last executed timestamp for this periodicjob tracked by the backend.
- #metadata : Metadata
- #observer : Observability::PeriodicJob
-
#pending_job_run? : Bool
Returns true if a previously enqueued job run has not yet finished.
-
#try_to_execute : Bool
Check the last executed timestamp against the current time, and enqueue the job if it's time to execute.
Constructor Detail
Instance Method Detail
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
Enqueues the job for execution and records the job run id so that subsequent intervals can detect that a run is already pending.
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.
Returns true if a previously enqueued job run has not yet finished. This prevents duplicate enqueues when executors are busy and the periodic interval elapses multiple times before the job is run.
Check the last executed timestamp against the current time, and enqueue the job if it's time to execute.