API Reference

Public API

EasyJobsBase.JobType
Job(core::Thunk; description="", username="")

Create a simple job.

Arguments

  • core: a Thunk 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");
source
EasyJobsBase.chain!Function
chain!(x::AbstractJob, y::AbstractJob, z::AbstractJob...)

Chain multiple AbstractJobs one after another.

source
EasyJobsBase.run!Function
run!(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.

source
EasyJobsBase.execute!Function
execute!(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.

source
EasyJobsBase.timecostofFunction
timecostof(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.

source
Thinkers.getresultFunction
getresult(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.

source

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.AsyncExecutorType
AsyncExecutor(; 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.
source