Skip to content

Latest commit

 

History

History
78 lines (64 loc) · 3.27 KB

Ref_JobResult_class.md

File metadata and controls

78 lines (64 loc) · 3.27 KB

JobResult Enum Class

Declaration: mle86\Job\JobResult
Source file: src/WQ/Job/JobResult.php

This class exists only to hold the job callback return status constants.

  • SUCCESS
  • FAILED
  • (ABORT)
  • (EXPIRED)

The WorkProcessor class assumes that the job handler function returns one of these constants (or null/no value, in which case DEFAULT will be used).

If you don't use the WorkProcessor class, you won't need this class either. If you do use the WorkProcessor class but your job handlers always either succeed or throw an exception, you won't need this class either – it's useful only if you want additional control over the re-try mechanism without throwing exceptions.

Constants

  • const int SUCCESS
    This status indicates that the job has been processed correctly and that it should now be deleted from the work queue.
    (It triggers the behavior set through the WorkProcessor's WP_DELETE option.)

  • const int FAILED
    This status indicates that the job has failed.
    If the job can be re-tried (according to its jobCanRetry() result), (according to its jobCanRetry() result and the WorkProcessor::WP_ENABLE_BURY option), it will be re-queued for later re-execution. If not, it will be buried.
    (That behavior may be changed through the WorkProcessor's WP_ENABLE_RETRY and WP_ENABLE_BURY options.)
    (The same thing happens if the job handler callback throws some RuntimeException.)

  • const int ABORT
    This status indicates that the job has failed and that it should not be re-tried, regardless of its jobCanRetry() result and the WP_ENABLE_RETRY setting. The job will immediately be buried/deleted (according to the WP_ENABLE_BURY setting).
    (The same thing happens if the job handler callback throws some non-RuntimeException exception.)

  • const int EXPIRED
    This status indicates that the job is actually expired and that it should be deleted (or whatever other action is indicated by the WP_EXPIRED setting).
    Usually, an expired job's jobIsExpired() method should return true right away which is the preferred way to indicate job expiration. But there might be situations in which the newly-unserialized Job cannot determine its own expiration without additional dependencies. The job handler callback however may be able to and that's why this constant exists.

  • const int DEFAULT = SUCCESS
    If the handler function returns null or no value at all, the WorkProcessor will use the default behavior set by this constant.