Skip to content

Commit 6376b98

Browse files
froemkenlinawolfsfroemkenjw
authored
[FEATURE] Add events for getObjectCountByQuery 1241 (#5747)
* Update MessageBus. ChangeLog2docs 1245 * A two new events. ChangeLog2docs 1241 * Update Documentation/ApiOverview/Events/Events/Extbase/Persistence/ModifyQueryBeforeFetchingObjectCountEvent.rst Co-authored-by: Lina Wolf <48202465+linawolf@users.noreply.github.com> * Update Documentation/ApiOverview/Events/Events/Extbase/Persistence/ModifyQueryBeforeFetchingObjectCountEvent.rst Co-authored-by: Lina Wolf <48202465+linawolf@users.noreply.github.com> * Update Documentation/ApiOverview/MessageBus/Index.rst Co-authored-by: Lina Wolf <48202465+linawolf@users.noreply.github.com> * Add header links * Add missing header anchors --------- Co-authored-by: Lina Wolf <48202465+linawolf@users.noreply.github.com> Co-authored-by: Stefan Froemken <sfroemken@jweiland.net>
1 parent 2c061c0 commit 6376b98

File tree

5 files changed

+104
-1
lines changed

5 files changed

+104
-1
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.. include:: /Includes.rst.txt
2+
.. index:: Events; ModifyQueryBeforeFetchingObjectCountEvent
3+
.. _ModifyQueryBeforeFetchingObjectCountEvent:
4+
5+
=========================================
6+
ModifyQueryBeforeFetchingObjectCountEvent
7+
=========================================
8+
9+
.. versionadded:: 14.0
10+
11+
The PSR-14 event
12+
:php:`\TYPO3\CMS\Extbase\Event\Persistence\ModifyQueryBeforeFetchingObjectCountEvent`
13+
is fired before the storage backend has asked for results count
14+
from a given query.
15+
16+
.. _ModifyQueryBeforeFetchingObjectCountEvent-api:
17+
18+
API
19+
===
20+
21+
.. include:: /CodeSnippets/Events/Extbase/ModifyQueryBeforeFetchingObjectCountEvent.rst.txt
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. include:: /Includes.rst.txt
2+
.. index:: Events; ModifyResultAfterFetchingObjectCountEvent
3+
.. _ModifyResultAfterFetchingObjectCountEvent:
4+
5+
=========================================
6+
ModifyResultAfterFetchingObjectCountEvent
7+
=========================================
8+
9+
.. versionadded:: 14.0
10+
11+
The PSR-14 event
12+
:php:`\TYPO3\CMS\Extbase\Event\Persistence\ModifyResultAfterFetchingObjectCountEvent`
13+
is fired after the storage backend has counted the results from a given query.
14+
15+
.. _ModifyResultAfterFetchingObjectCountEvent-api:
16+
17+
API
18+
===
19+
20+
.. include:: /CodeSnippets/Events/Extbase/ModifyResultAfterFetchingObjectCountEvent.rst.txt

Documentation/ApiOverview/MessageBus/Index.rst

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,13 @@ of a consumer command.
3636
:local:
3737

3838

39+
.. _message-bus-everyday-usage:
40+
3941
"Everyday" usage - as a developer
4042
=================================
4143

44+
.. _message-bus-dispatch:
45+
4246
Dispatch a message
4347
------------------
4448

@@ -179,6 +183,8 @@ file on your server:
179183
WantedBy=multi-user.target
180184
181185
186+
.. _message-bus-advanced-usage:
187+
182188
Advanced usage
183189
==============
184190

@@ -220,6 +226,37 @@ The TYPO3 Core has been tested with three transports:
220226
* :php:`\Symfony\Component\Messenger\Transport\InMemory\InMemoryTransport`
221227
(for testing)
222228

229+
.. _message-bus-add-rate-limiter:
230+
231+
Add rate limiter
232+
----------------
233+
234+
.. versionadded:: 13.4
235+
236+
Rate limiting can be applied to asynchronous messages processed through the
237+
consume command. This allows controlling message processing rates to:
238+
239+
* Stay within external service limits (API quotas, mail sending thresholds)
240+
* Manage server resource utilization
241+
242+
.. _message-bus-example-rate-limiter:
243+
244+
Example: Usage of a rate limiter
245+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
246+
247+
Use the following configuration to limit the process of messages to
248+
max. 100 each 60 seconds:
249+
250+
.. literalinclude:: _add-rate-limiter.yaml
251+
:language: yaml
252+
:caption: EXT:my_extension/Configuration/Services.yaml | config/system/services.yaml
253+
254+
.. hint::
255+
As TYPO3 default transport for asynchronous messages is `doctrine` you also
256+
have to set the tags `identifier` to `doctrine`.
257+
258+
259+
.. _message-bus-in-memory-transport-testing:
223260

224261
InMemoryTransport for testing
225262
-----------------------------
@@ -232,6 +269,8 @@ testing.
232269
:caption: EXT:my_extension/Configuration/Services.yaml | config/system/services.yaml
233270

234271

272+
.. _message-bus-configure-middleware:
273+
235274
Configure a custom middleware
236275
-----------------------------
237276

@@ -249,7 +288,6 @@ order using TYPO3's :yaml:`before` and :yaml:`after` ordering mechanism:
249288
:caption: EXT:my_extension/Configuration/Services.yaml | config/system/services.yaml
250289

251290

252-
253291
.. _Custom middleware: https://symfony.com/doc/current/components/messenger.html#bus
254292
.. _Doctrine DBAL messenger transport: https://github.com/symfony/doctrine-messenger
255293
.. _Message Bus and Message Queue in TYPO3: https://usetypo3.com/messages-in-typo3.html
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
messenger.rate_limiter.limit_db_messages:
2+
class: Symfony\Component\RateLimiter\RateLimiterFactory
3+
arguments:
4+
$config:
5+
id: 'limit_db_messages'
6+
policy: 'sliding_window'
7+
limit: 100
8+
interval: '60 seconds'
9+
$storage: '@TYPO3\CMS\Core\RateLimiter\Storage\CachingFrameworkStorage'
10+
tags:
11+
- name: 'messenger.rate_limiter'
12+
identifier: 'doctrine'

Documentation/CodeSnippets/Config/Api/Events/EventsExtbase.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@
4343
'targetFileName' => 'CodeSnippets/Events/Extbase/EntityUpdatedInPersistenceEvent.rst.txt',
4444
'withCode' => false,
4545
],
46+
[
47+
'action' => 'createPhpClassDocs',
48+
'class' => \TYPO3\CMS\Extbase\Event\Persistence\ModifyQueryBeforeFetchingObjectCountEvent::class,
49+
'targetFileName' => 'CodeSnippets/Events/Extbase/ModifyQueryBeforeFetchingObjectCountEvent.rst.txt',
50+
'withCode' => false,
51+
],
52+
[
53+
'action' => 'createPhpClassDocs',
54+
'class' => \TYPO3\CMS\Extbase\Event\Persistence\ModifyResultAfterFetchingObjectCountEvent::class,
55+
'targetFileName' => 'CodeSnippets/Events/Extbase/ModifyResultAfterFetchingObjectCountEvent.rst.txt',
56+
'withCode' => false,
57+
],
4658
[
4759
'action' => 'createPhpClassDocs',
4860
'class' => \TYPO3\CMS\Extbase\Event\Persistence\ModifyQueryBeforeFetchingObjectDataEvent::class,

0 commit comments

Comments
 (0)