-
Notifications
You must be signed in to change notification settings - Fork 122
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
RES 3.0 integration #1561
Draft
mostlyobvious
wants to merge
59
commits into
master
Choose a base branch
from
next
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.
Draft
RES 3.0 integration #1561
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
mostlyobvious
force-pushed
the
next
branch
14 times, most recently
from
January 30, 2023 16:14
56f4bb3
to
5af6725
Compare
done |
Projection class is redesigned here. It now only suports read & reduce based on existing events, without possibility to subscribe for events. New & redesigned: * replace `from_all_streams` & `from_stream` with passing read scopes to `call` method, it allows to fully use all read specification features to define what events should be handled * instead of providing several streams (and starting points) to be processed `call` expects several read scopes * `when` method replaced with `on` method, with usage consistent with `on` handlers (as in `AggregateRoot`), the `on` methods require block to process state & event and it must return new projection state * allows to use simple values as initial state, no need to use hash to pass values, `nil` is the initial default state now * initial state is passed to projection using costructor Typical usage: ```ruby account_balance = RailsEventStore::Projection .new(0.0) .on(MoneyDeposited) { |state, event| state += event.data[:amount] } .on(MoneyWithdrawn) { |state, event| state -= event.data[:amount] } .call(client.read) ```
DefaultApplyStrategy relies on OnDSL. Therefore they always have to go together. https: //github.com//issues/982 Co-authored-by: Paweł Pacana <[email protected]> Co-authored-by: Szymon Fiedler <[email protected]>
Co-authored-by: Szymon Fiedler <[email protected]> Co-authored-by: Paweł Pacana <[email protected]>
Co-authored-by: Paweł Pacana <[email protected]> Co-authored-by: Szymon Fiedler <[email protected]>
Co-authored-by: Paweł Pacana <[email protected]> Co-authored-by: Szymon Fiedler <[email protected]>
All we need is subscriber responding to `call` method. Therefore, passing class is not allowed anymore. It either has to be class instance or something that evaluates to class instance.
The dispatcher doesn't indicate that the message will be handled asynchronously. It indicates that the event will be dispatched immediately. No matter if it's handled sync or async
Basically same reason as ImmediateAsyncDispatcher -> ImmediateDispatcher
Co-authored-by: Paweł Pacana <[email protected]> Co-authored-by: Szymon Fiedler <[email protected]>
Co-authored-by: Paweł Pacana <[email protected]>
Not a practical example. Hard to imagine real life use case for passing anonymous class. Co-authored-by: Paweł Pacana <[email protected]>
Co-authored-by: Paweł Pacana <[email protected]>
During an attempt to introduce event_type_resolver into projection I wrote following test. The idea is that you can use two different versions of event with class level method defining the event type. In that case, and in usage presented as in test, the event_type_resolver doesn't bring any value to the projection class. So for now I removed it. Perhaps it does make more sense if we're thinking of other way of using projections?
Rely on the new default instead of explicitly setting it
The reason is the "Why we’re deprecating the automatic conversion" section in the article below https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/
Co-authored-by: Szymon Fiedler <[email protected]>
Co-authored-by: Szymon Fiedler <[email protected]>
Co-authored-by: Szymon Fiedler <[email protected]>
Co-authored-by: Szymon Fiedler <[email protected]>
Co-authored-by: Szymon Fiedler <[email protected]>
Mutant had a doubt that Transformation::ProtobufNestedStructMetadata is passed. When not passed, tests would fail on deserialize part not being able to merge timestamp and valid_at to already serialized binary string. No test checked how messages is serialized to prove that transformation is needed.
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.
All breaking 3.0 changes in one place.
Including:
RailsEventStore
aliases onRubyEventStore
constsjsonb
columns, thus minimal supported Rails version 6.1ArgumentError
when passingnil
topublish
andlink
rails_event_store_active_record
wrapper and depending directly onruby_event_store-active_record
gem inrails_event_store
JSONMapper
NullMapper
apply_guessed_method_name_from_event
in AggregateRootEventClassRemapper
(upcasting is a preferred alternative)InMemoryRepository
detecting mixed usage ofexpected_version
(:any
+Integer
) by defaultEventClassRemapper
toruby_event_store-transformations
gem in case someone relied on itNice to have:
opportunity to further redesign Projection and reuse Extract component for sourcing from events #1175