Replace BatchableSubscriber interface with batch attributes#865
Open
DavidBadura wants to merge 6 commits into
Open
Replace BatchableSubscriber interface with batch attributes#865DavidBadura wants to merge 6 commits into
DavidBadura wants to merge 6 commits into
Conversation
Subscribers no longer implement the BatchableSubscriber interface to take part in batching. Instead the batch lifecycle is declared with attributes: #[BatchBegin], #[BatchFlush], #[BatchRollback] and #[BatchShouldFlush], with #[BatchState] to inject the per-batch state into a subscribe handler. This keeps batching consistent with the rest of the subscriber API, which is already attribute and argument-resolver driven. The metadata factory now reads these into a BatchMetadata and rejects duplicate or incomplete batch method sets. Argument resolution for handlers moved into the MessageProcessor, and a BatchManager/Batch pair tracks the open batch per subscription. Upgrade notes and the subscription docs are updated accordingly.
ArgumentMetadata now carries the list of attribute instances attached to a subscribe handler parameter, with an attribute() lookup helper, rather than a dedicated bool for BatchState. The batch argument resolver and the metadata factory ask for the BatchState attribute through that list, which keeps the metadata generic for future parameter attributes. Also fixes the nullsafe chain in BatchSubscriber, where metadata() was called on a possibly-null accessor before the null check.
|
Hello 👋 here is the most recent benchmark result:
This comment gets update everytime a new commit comes in! |
The event emitter section passed argumentResolvers to MetadataSubscriberAccessorRepository, which no longer takes them. Resolvers are registered on the DefaultSubscriptionEngine, matching the upgrade guide.
The lookup resolver is not registered by default, so show how to pass it to the subscription engine, the same as the event emitter resolver.
Every caller only checks for presence, so a bool hasAttribute() reads better than returning the attribute instance.
Add tests for ArgumentMetadata::hasAttribute, the usesBatching attribute detection, message argument resolving in MessageProcessor and the afterMessages flush path of the batch subscriber.
This file contains hidden or 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
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.
Batching for subscribers no longer relies on the
BatchableSubscriberinterface. The batch lifecycle is now declared with attributes, in line with the rest of the subscriber API which is already attribute and argument-resolver driven.A subscriber opts into batching with
#[BatchBegin],#[BatchFlush],#[BatchRollback]and optionally#[BatchShouldFlush]. The begin method may return a state object, which is injected into subscribe handlers via the#[BatchState]parameter attribute and passed to flush/rollback.