apinstein / jqjobs

A job queue engine for PHP.
32 stars 5 forks source link

Refactor code to resolve jobs in WAIT_ASYNC into JQManagedJob. Add tests... #24

Closed apinstein closed 10 years ago

apinstein commented 10 years ago

....

apinstein commented 10 years ago
JQManagedJob
 [x] Exception when asked to manage a second job
 [x] Resolve async to state
 [x] Resolve async exception marks job failed when convert exceptions to failures is enabled
 [x] Resolve async exception leaves in wait async by default
 [x] Resolve async job does not exist throws exception
 [x] Resolve async job uses mutex
 [x] Resolve async job clears mutex on failure
 [x] Resolve async job clears mutex on exception
apinstein commented 10 years ago

@lorennorman woot

apinstein commented 10 years ago

@lorennorman I added one more thing you need on your end; to detect if the job isn't in wait_async (happens if for some reason 2 webhooks ping us at the same time; first will "finish normally" and second will find an already completed job (well it's a race condition; it might find a compeleted one, a failed one, or a missing one).

JQManagedJob
 [X] JQManagedJob::resolveWaitAsyncJob(): will throw JQManagedJob_InvalidStateException if job is STATUS_QUEUED
 [X] JQManagedJob::resolveWaitAsyncJob(): will throw JQManagedJob_InvalidStateException if job is STATUS_RUNNING
 [X] JQManagedJob::resolveWaitAsyncJob(): will run if job is STATUS_WAIT_ASYNC
 [X] JQManagedJob::resolveWaitAsyncJob(): will throw JQManagedJob_InvalidStateException if job is STATUS_COMPLETED
 [X] JQManagedJob::resolveWaitAsyncJob(): will throw JQManagedJob_InvalidStateException if job is STATUS_FAILED
apinstein commented 10 years ago

@lorennorman I am pretty sure this is 100% done now unless you run across a problem.