Job
abstract class Job implements Job, JobLifecycleCallbacks
Traits
Properties
| protected mixed | $instance | The job handler instance. |
|
| protected array|null | $decodedPayload | The validated job payload. |
|
| protected InvalidPayloadException|null | $payloadException | The exception raised while validating the job payload. |
|
| protected Container | $container | The IoC container instance. |
|
| protected bool | $deleted | Indicates if the job has been deleted. |
|
| protected bool | $released | Indicates if the job has been released. |
|
| protected bool | $failed | Indicates if the job has failed. |
|
| protected Closure> | $beforeReleasingCallbacks | The callbacks to run before releasing the job. |
|
| protected Closure> | $beforeFailingCallbacks | The callbacks to run before recording the job as failed. |
|
| protected string | $connectionName | The name of the connection the job belongs to. |
|
| protected string | $queue | The name of the queue the job belongs to. |
|
| protected Lease|null | $poolLease | The lease pinning this job's pooled backend until a terminal operation. |
|
| protected bool | $poolLeaseAttached | Indicates whether this job has ever carried a pool lease. |
Methods
Get the number of seconds until the given DateTime.
Get the "available at" UNIX timestamp.
If the given value is an interval, convert it to a DateTime instance.
Given a start time, format the total run time for human readability.
Get the job identifier.
Get the raw body of the job.
Initialize state that must be captured while the backend is pinned.
Return the pinned backend to its pool.
Discard the pinned backend instead of returning it to its pool.
Determine whether a previously attached backend lease is finalized.
Discard a backend after failure without masking the primary exception.
Get the UUID of the job.
Fire the job.
Delete the job from the queue.
Determine if the job has been deleted.
Release the job back into the queue after (n) seconds.
Run the callbacks before making another attempt available.
Determine if the job was released back into the queue.
Determine if the job has been deleted or released.
Determine if the job has been marked as a failure.
Mark the job as "failed".
Run the callbacks before publishing the failure.
Determine if the current database transaction should be rolled back to level zero.
Resolve the given class.
Get the resolved job handler instance.
Get the decoded body of the job.
Get the number of times to attempt a job.
Get the number of times to attempt a job after an exception.
Determine if the job should fail when it timeouts.
The number of seconds to wait before retrying a job that encountered an uncaught exception.
Get the number of seconds the job can run.
Get the timestamp indicating when the job should timeout.
Get the name of the queued job class.
Get the resolved display name of the queued job class.
Get the class of the queued job.
Get the name of the connection the job belongs to.
Get the name of the queue the job belongs to.
Get the service container instance.
Details
in
InteractsWithTime at line 17
protected int
secondsUntil(DateInterval|DateTimeInterface|int $delay)
Get the number of seconds until the given DateTime.
in
InteractsWithTime at line 29
protected int
availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)
Get the "available at" UNIX timestamp.
in
InteractsWithTime at line 47
protected DateTimeInterface|int
parseDateInterval(DateInterval|DateTimeInterface|int|null $delay)
If the given value is an interval, convert it to a DateTime instance.
in
InteractsWithTime at line 63
protected int
currentTime()
Get the current system time as a UNIX timestamp.
in
InteractsWithTime at line 71
protected string
runTimeForHumans(float $startTime, float|null $endTime = null)
Given a start time, format the total run time for human readability.
at line 101
abstract int|string|null
getJobId()
Get the job identifier.
at line 106
abstract string
getRawBody()
Get the raw body of the job.
at line 129
protected void
onPoolLeaseAttached()
Initialize state that must be captured while the backend is pinned.
at line 136
protected void
releasePoolLease()
Return the pinned backend to its pool.
at line 147
protected void
discardPoolLease()
Discard the pinned backend instead of returning it to its pool.
at line 158
protected bool
poolLeaseIsFinalized()
Determine whether a previously attached backend lease is finalized.
at line 166
protected never
discardPoolLeaseAfterFailure(Throwable $exception)
Discard a backend after failure without masking the primary exception.
at line 181
string|null
uuid()
Get the UUID of the job.
at line 189
void
fire()
Fire the job.
at line 201
void
delete()
Delete the job from the queue.
at line 209
bool
isDeleted()
Determine if the job has been deleted.
at line 217
void
release(int $delay = 0)
Release the job back into the queue after (n) seconds.
at line 227
JobLifecycleCallbacks
beforeReleasing(Closure $callback)
Register a callback to run before releasing the job.
at line 237
protected void
runBeforeReleasingCallbacks()
Run the callbacks before making another attempt available.
at line 247
bool
isReleased()
Determine if the job was released back into the queue.
at line 255
bool
isDeletedOrReleased()
Determine if the job has been deleted or released.
at line 263
bool
hasFailed()
Determine if the job has been marked as a failure.
at line 271
void
markAsFailed()
Mark the job as "failed".
at line 279
JobLifecycleCallbacks
beforeFailing(Closure $callback)
Register a callback to run before recording the job as failed.
at line 289
protected void
runBeforeFailingCallbacks()
Run the callbacks before publishing the failure.
at line 299
void
fail(Throwable|null $e = null)
Delete the job, call the "failed" method, and raise the failed job event.
at line 377
protected bool
shouldRollBackDatabaseTransaction(Throwable|null $e)
Determine if the current database transaction should be rolled back to level zero.
at line 393
protected void
failed(Throwable|null $e)
Process an exception that caused the job to fail.
at line 407
protected mixed
resolve(string $class)
Resolve the given class.
at line 415
mixed
getResolvedJob()
Get the resolved job handler instance.
at line 423
array
payload()
Get the decoded body of the job.
at line 464
int|null
maxTries()
Get the number of times to attempt a job.
at line 472
int|null
maxExceptions()
Get the number of times to attempt a job after an exception.
at line 480
bool
shouldFailOnTimeout()
Determine if the job should fail when it timeouts.
at line 490
array|int|string|null
backoff()
The number of seconds to wait before retrying a job that encountered an uncaught exception.
at line 498
int|null
timeout()
Get the number of seconds the job can run.
at line 506
int|null
retryUntil()
Get the timestamp indicating when the job should timeout.
at line 514
string
getName()
Get the name of the queued job class.
at line 524
string
resolveName()
Get the resolved display name of the queued job class.
Resolves the name of "wrapped" jobs such as class-based handlers.
at line 534
string
resolveQueuedJobClass()
Get the class of the queued job.
Resolves the class of "wrapped" jobs such as class-based handlers.
at line 542
string
getConnectionName()
Get the name of the connection the job belongs to.
at line 550
string
getQueue()
Get the name of the queue the job belongs to.
at line 558
Container
getContainer()
Get the service container instance.