CRM_Queue_Runner - Add basic/skeletal support for runAllInteractively()
#23746
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
The helper class
CRM_Queue_Runner
provides methods for working through the tasks in a queue. This adds another one (runAllInteractively()
) and a setting (enableBackgroundQueue
). This arrangement allows the sysadmin to decide how to run tasks. It is flaggedEXPERIMENTAL
.The method
runAllInteractively()
is similar to the existingrunAllViaWeb()
, but it is not necessarily executed via web-browser - it can be supplemented (depending on system config) by background/multiprocessing tasks, and it has somewhat tighter requirements/constraints. (These constraints are validated upfront.)Before
There are two mechanisms/helpers:
runAll()
synchronously executes all tasks in a queue (until the queue is empty).runAllViaWeb()
redirects the user another web-page and runs the queue. This other page displays the progress of the queue, and it actively executes each task, 1-by-1.After
Adds a third mechanism/helper:
runAllInteractively()
redirects the user to another web-page and runs the queue. However, it do so in a few different ways. It depends on the settingenableBackgroundQueue
:enableBackgroundQueue=0
), it will do exactly the same asrunAllViaWeb()
.enableBackgroundQueue=1
), it will send the queue for execution by a background task-runner. The web browser will redirect to a monitoring page.The new setting
enableBackgroundQueue
is flagged "EXPERIMENTAL". The default is fully functional/equivalent/compatible with current behavior.Comments
General:
runAllInteractively()
should have no impact on existing callers that userunAll()
orrunAllViaWeb()
.civicrm/queue/monitor
. It needs a widget to actually... monitor the progress.runAllInteractively()
andcivicrm/queue/monitor
do not support the optiononEnd
. There are a couple reasons:universe
, this option is often used for manipulating session-status-messages or to issue HTTP redirects. This is not portable to background queues.onEnd
is/was a configurable callback. The most obvious place to store this is (civicrm_user_job.metadata
), and that is API-CRUDable - which means its not safe to store a callback there.hook_civicrm_queueStatus
.To test this, I used
demoqueue
andcoworker
, ieThen I had console runner
coworker
. It received an executed the tasks