-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(REF) Queue - Extract better helper for batch operations #31908
Open
totten
wants to merge
9
commits into
civicrm:master
Choose a base branch
from
totten:master-queue-handler
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷 Introduction for new contributors...
Quick links for reviewers...
|
@totten did the one I just merged make this stale? |
This splits the class `CRM_Queue_TaskRunner` in two parts: * `CRM_Queue_BasicHandler` is a queue-listener that breaks-down a batch and individually executes each item. It enforces queue options like `retry_limit=>5` and `error=>abort` * `CRM_Queue_TaskHandler` specifically handles instances of `CRM_Queue_Task`.
…d items This is basically the same as `releaseItems()`, but it doesn't count toward the retry-limit.
This preserves the quirk of `CRM_Queue_Task` where callbacks are expected to return booleans. However, for logic implemented directly on `BasicHandler`, you can follow a simpler protocol. (Void-return on success. Exception for error.)
totten
force-pushed
the
master-queue-handler
branch
from
January 29, 2025 03:13
ba60215
to
777fd8f
Compare
@eileenmcnaughton Doh! Yes, that's what happened. I've rebased. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Background
Recall that:
CRM_Queue_Task
s). Additionally, they can process arbitrary kinds of data (egarray
s).hook_civicrm_queueRun_{XXX}
as a way to process batches of data. (Example Extension)Overview
hook_civicrm_queueRun_{XXX}
provides basic wiring to handle a batch of data from a queue. However, support for batching is a double-edged sword for the downstream hook-implementer:This PR speaks to the scenario where:
array
not aTask
), sohook_civicrm_queueRun_{XXX}
, butThe implementation is based on the existing (internal) implementation of
CRM_Queue_TaskRunner
(which has similar goal/problem/situation). It reorganizes that code and extracts helpers so that we can reuse the logic for other (non-task
) data.Before
hook_civicrm_queueRun_task
, it calls out toCRM_Queue_TaskRunner
.task
s), you need a bunch of loops+conditionals. You basically need to copyCRM_Queue_TaskRunner
and replace the$task->run()
step.After
hook_civicrm_queueRun_task
, it calls out toCRM_Queue_TaskHandler
.task
s), you can create another class like this:Comments
CRM_Queue_TaskRunner
. There are no references to that symbol inuniverse
.api\v4\Entity\QueueTest
).