Repository navigation
FEATURE: Filtered reads for subscribers - #20
Merged
Merged
Conversation
A subscriber can declare an adapter specific filter. Runs with a single subscription pass it to the adapter, bounded by a snapshot of `lastPosition()`, and move the subscription to that snapshot once the read is exhausted, so gaps without matching events are not rescanned. Runs with several subscriptions share one unfiltered read and apply the filters through the new `EventStoreAdapter::matches()`. Breaking: `EventStoreAdapter::read()` takes a `ReadOptions` object with `limit`, `upTo` and `filter` instead of `int|null $limit`, and adapters have to implement `matches()`.
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.
Summary
Subscribers can declare an adapter-specific filter. The filter type is opaque to core (
EventStoreAdapter<E, F>).Adapter contract (breaking):
How a run reads:
limitcounts events returned byread(), i.e. matching events in filtered single-subscription runshasPendingEventsshortcut ofcatchUpNextActive()only applies if there was nothing to readreset()Reasoning and known consequences:
docs/decisions.md→ "Filtered reads". Usage:docs/how-it-works.md→ "Filtered subscribers". Adapter changes:docs/upgrading.md.Evidence
After: 11 new engine tests + 3 for
ReadOptions,composer testgreen (141 tests). For example:bootNext(limit: 1)/catchUpNextActive(limit: 5)loops):Queryfilters of subscribers subscription-engine-dcb-adapter#4 and FEATURE: SupportNeosEventFilterfilters and neos/eventstore 2.x subscription-engine-neos-adapter#2. Doctrine store integration tests (PostgreSQL) and worker integration tests are green against this branch.Merge Danger
Door: two-way until 2.0 is tagged, one-way afterwards
The
read()signature andmatches()are final for 2.0. A change after the tag would break every adapter again.Blast Radius: adapters
Every
EventStoreAdapterimplementation fails with a fatal error until it implements the newread()andmatches(). They can't support 1.x at the same time anymore, so the dcb and neos adapters require^2. Engine users see no change unless they set a filter.