class
Mosquito::JobRun
- Mosquito::JobRun
- Reference
- Object
Overview
A JobRun is a unit of work which will be performed by a Job. JobRuns know how to:
- store and retrieve their data to and from the datastore
- figure out what Job class they match to
- build an instance of that Job class and pass off the config data
- Ask the job to run
JobRun data is called config and is persisted in the backend under the key
mosquito:job_run:job_run_id.
Defined in:
mosquito/job_run.crConstant Summary
-
CONFIG_KEY_PREFIX =
"job_run"
Constructors
Class Method Summary
-
.config_key(*parts)
The config key is the backend storage key for the metadata of this job_run.
-
.retrieve(id : String)
Used to construct a job_run from the parameters stored in the backend.
Instance Method Summary
-
#==(other : self)
Returns
trueif this reference is the same as other. -
#build_job : Mosquito::Job
Builds a Job instance from this job_run.
-
#claimed_by(overseer : Runners::Overseer)
Marks this job run as claimed by the given overseer and persists the association to the backend.
-
#config_key
The config key is the backend storage key for the metadata of this job_run.
-
#delete(in ttl : Int = 0)
Deletes this job_run from the backend.
- #enqueue_time : Time
-
#fail
Fails this job run and make sure it's persisted as such.
- #finished_at : Time | Nil
- #id : String
- #job : Mosquito::Job | Nil
- #job! : Mosquito::Job
- #overseer_id : String | Nil
-
#reload : Nil
Updates this job_run config from the backend.
-
#reschedule_interval
For the current retry count, how long should a runner wait before retry?
-
#rescheduleable?
For the current retry count, is the job rescheduleable?
- #retry_count : Int32
-
#retry_or_banish(queue : Queue) : Nil
Treats this job run as a failure: increments the retry count and either reschedules with backoff or banishes to the dead queue.
-
#run
Builds and runs the job with this job_run config.
- #started_at : Time | Nil
-
#store
Stores this job run configuration and metadata in the backend.
-
#to_s(io : IO)
Appends a short String representation of this object which includes its class name and its object address.
- #type : String
Constructor Detail
Class Method Detail
The config key is the backend storage key for the metadata of this job_run.
Used to construct a job_run from the parameters stored in the backend.
Instance Method Detail
Returns true if this reference is the same as other. Invokes same?.
Builds a Job instance from this job_run. Populates the job with config from the backend.
Marks this job run as claimed by the given overseer and persists the association to the backend. Used by the pending cleanup to determine whether the owning overseer is still alive.
Deletes this job_run from the backend. Optionally, after a delay in seconds (handled by the backend).
Fails this job run and make sure it's persisted as such. Clears the overseer_id since the job is no longer in-flight.
Treats this job run as a failure: increments the retry count and either reschedules with backoff or banishes to the dead queue.
Stores this job run configuration and metadata in the backend. Nil-valued fields are deleted from the backend hash.
Appends a short String representation of this object which includes its class name and its object address.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).to_s # => #<Person:0x10a199f20>