API Reference
Public API
EasyJobsBase.Job
— TypeJob(core::Thunk; description="", username="")
Create a simple job.
Arguments
core
: aThunk
that encloses the job core definition.name
: give a short name to the job.description::String=""
: describe what the job does in more detail.username::String=""
: indicate who executes the job.
Examples
julia> using Thinkers
julia> a = Job(Thunk(sleep, 5); username="me", description="Sleep for 5 seconds");
julia> b = Job(Thunk(run, `pwd` & `ls`); username="me", description="Run some commands");
EasyJobsBase.chain!
— Functionchain!(x::AbstractJob, y::AbstractJob, z::AbstractJob...)
Chain multiple AbstractJob
s one after another.
EasyJobsBase.:→
— Function→(x, y)
Chain two AbstractJob
s.
EasyJobsBase.:←
— Function←(y, x)
Chain two AbstractJob
s reversely.
EasyJobsBase.run!
— Functionrun!(job::Job; maxattempts=1, interval=1, delay=0, wait=false)
run!(job::Job, worker::Integer; maxattempts=1, interval=1, delay=0, wait=false)
Run a Job
with a maximum number of attempts, with each attempt separated by interval
seconds and an initial delay
in seconds.
EasyJobsBase.execute!
— Functionexecute!(job::AbstractJob, exec::Executor)
Execute a given AbstractJob
associated with the Executor
.
This function checks if the job
has succeeded. If so, it stops immediately. If not, it sleeps for a exec.delay
, then runs the job
. If exec.maxattempts
is more than $1$, it loops over the remaining attempts, sleeping for an exec.interval
, running the job
, and waiting in each loop.
EasyJobsBase.getstatus
— Functiongetstatus(job::AbstractJob)
Get the current status of the job
.
EasyJobsBase.ispending
— Functionispending(job::AbstractJob)
Test if the job
is still pending.
EasyJobsBase.isrunning
— Functionisrunning(job::AbstractJob)
Test if the job
is running.
EasyJobsBase.isexited
— Functionisexited(job::AbstractJob)
Test if the job
has exited.
EasyJobsBase.issucceeded
— Functionissucceeded(job::AbstractJob)
Test if the job
was successfully run.
EasyJobsBase.isfailed
— Functionisfailed(job::AbstractJob)
Test if the job
failed during running.
EasyJobsBase.listpending
— Functionlistpending(jobs)
Filter the pending jobs in a sequence of jobs.
EasyJobsBase.listrunning
— Functionlistrunning(jobs)
Filter the running jobs in a sequence of jobs.
EasyJobsBase.listexited
— Functionlistexited(jobs)
Filter the exited jobs in a sequence of jobs.
EasyJobsBase.listsucceeded
— Functionlistsucceeded(jobs)
Filter the succeeded jobs in a sequence of jobs.
EasyJobsBase.listfailed
— Functionlistfailed(jobs)
Filter the failed jobs in a sequence of jobs.
EasyJobsBase.countexecution
— Functioncountexecution(job::AbstractJob)
Count how many times the job
has been run.
EasyJobsBase.descriptionof
— Functiondescriptionof(job::AbstractJob)
Return the description of the job
.
EasyJobsBase.creationtimeof
— Functioncreationtimeof(job::AbstractJob)
Return the creation time of the job
.
EasyJobsBase.starttimeof
— Functionstarttimeof(job::AbstractJob)
Return the start time of the job
. Return nothing
if it is still pending.
EasyJobsBase.endtimeof
— Functionendtimeof(job::AbstractJob)
Return the end time of the job
. Return nothing
if it has not exited.
EasyJobsBase.timecostof
— Functiontimecostof(job::AbstractJob)
Return the time cost of the job
since it started running.
If nothing
, the job
is still pending. If it is finished, return how long it took to complete.
Thinkers.getresult
— Functiongetresult(job::AbstractJob)
Get the running result of the job
.
The result is wrapped by a Some
type. Use something
to retrieve its value. If it is nothing
, the job
is not finished.
EasyJobsBase.countparents
— Functioncountparents(job::AbstractJob)
Count the number of parent jobs for a given job
.
EasyJobsBase.countchildren
— Functioncountchildren(job::AbstractJob)
Count the number of child jobs for a given job
.
Private API
The functions and types mentioned here are considered part of the private API and are not intended for direct use by users. They may be modified, moved, or removed without notice and are primarily meant for internal use within the package. Using them directly may result in unexpected errors or compatibility issues in your code.
EasyJobsBase.AsyncExecutor
— TypeAsyncExecutor(; maxattempts=1, interval=1, delay=0, wait=false)
Handle the asynchronous execution of jobs.
Arguments
maxattempts::UInt64=1
: the maximum number of attempts to execute the job.interval::Real=1
: the time interval between each attempt to execute the job, in seconds.delay::Real=0
: the delay before the first attempt to execute the job, in seconds.wait::Bool=false
: determines whether to wait for the job to complete before executing the next task.