Overview
TheJob class represents a single unit of work in a workflow. It wraps an action (either an ActionInterface, a class string, or a Closure) and manages its arguments, dependencies, execution conditions, and retry policy.
Jobs should be created using the
sync() or async() helper functions rather than instantiating the Job class directly.Class signature
Chevere\Workflow\Interfaces\JobInterface
Location: src/Job.php:39
Constructor
The action to run. Can be an action instance, an action class string, or a callable.
Action arguments for its run method. Can be raw values, response references, or variables.
Public methods
parameters()
Provides access to the invocable action parameters for this job.The parameters interface containing all parameter definitions for the job’s action.
src/Job.php:142
return()
Provides access to the return type parameter for this job.The parameter interface describing the job’s return type.
src/Job.php:147
action()
Returns the action associated with this job.The action to be executed by this job.
src/Job.php:208
arguments()
Returns the arguments that will be passed to the action.An associative array of argument names to values.
src/Job.php:213
dependencies()
Returns the job dependencies.A vector containing the names of jobs that this job depends on.
src/Job.php:218
runIf()
Returns the run-if conditions for this job.A vector of conditions that must be truthy for the job to execute.
src/Job.php:223
runIfNot()
Returns the run-if-not conditions for this job.A vector of conditions that must be falsy for the job to execute.
src/Job.php:228
isSync()
Determines if the job is synchronous (blocking).Returns
true if the job is synchronous, false if asynchronous.src/Job.php:233
caller()
Provides access to the caller who created this job.Information about where the job was created (file and line number).
src/Job.php:137
retryPolicy()
Provides access to the job retry policy.The retry policy configuration for this job.
src/Job.php:152
withArguments()
Returns an instance with the specified arguments.Arguments to set for the job. Can be raw values, response references, or variables.
A new instance with the specified arguments. The current instance is not modified.
src/Job.php:157
Example:
withRunIf()
Returns an instance with the specified run-if condition.Conditions that must be truthy for the job to execute. Multiple conditions are combined with AND logic.
A new instance with the specified run-if conditions. The current instance is not modified.
src/Job.php:165
Example:
withRunIfNot()
Returns an instance with the specified run-if-not condition.Conditions that must be falsy for the job to execute. Multiple conditions are combined with AND logic.
A new instance with the specified run-if-not conditions. The current instance is not modified.
src/Job.php:173
Example:
withIsSync()
Returns an instance with the specified sync flag.Set to
true for synchronous execution, false for asynchronous.A new instance with the specified sync flag. The current instance is not modified.
src/Job.php:181
Example:
withDepends()
Returns an instance with the specified job dependencies.Names of jobs that this job depends on. The job will not execute until all dependencies complete.
A new instance with the specified dependencies. The current instance is not modified.
src/Job.php:189
Example:
withRetry()
Returns an instance with the specified retry policy.Timeout in seconds across all attempts. Use
0 for unlimited.Number of execution attempts (minimum 1).
Retry delay in seconds between attempts. Use
0 for no delay.A new instance with the specified retry policy. The current instance is not modified.
src/Job.php:197
Example:
Usage example
See also
- sync() function - Create a synchronous job
- async() function - Create an asynchronous job
- JobInterface - Job interface specification
- RetryPolicy class - Retry policy configuration