SqlParallel - Implement BatchQueueInterface
authorTim Otten <totten@civicrm.org>
Fri, 11 Feb 2022 09:07:25 +0000 (01:07 -0800)
committerTim Otten <totten@civicrm.org>
Thu, 2 Jun 2022 20:31:59 +0000 (13:31 -0700)
commit0374a8cc0dedd8f421367805a2bce804f2fb96e8
tree49444bcc0542f81967337847cde829a832973586
parent4e276ae407d21b531727964df98ec9088acec196
SqlParallel - Implement BatchQueueInterface

Before
------

Each of the `CRM_Queue_Queue_*` drivers supports a set of methods for
claiming/releasing one queue-item at a time (eg `claimItem()`,
`releaseItem()`, `deleteItem()`).

After
-----

All drivers still support the same queue-item methods.  Additionally, the
`SqlParallel` driver supports batch-oriented equivalents (`claimItems()`,
`deleteItems()`, etc).

Comments
--------

I initially looked at updating all of the drivers to support queues.  There
were a few obstacles.  Firstly, batched-claims seem semantically
questionable for queues that run 1-by-1 (`Sql`, `Memory`).  Secondly, there
are a few extensions in contrib that extend these classes and override
methods (consequently, they're looking for stable signatures).

The approach here seemed to resolve those two concerns in an OOP-safe way:
define an optional interface (`BatchQueueInterface`) which can be used to
mark enhanced functionality on queues where it makes sense (eg
`SqlParallel`).
CRM/Queue/Queue/BatchQueueInterface.php [new file with mode: 0644]
CRM/Queue/Queue/SqlParallel.php
CRM/Queue/Queue/SqlTrait.php
tests/phpunit/CRM/Queue/QueueTest.php