Skip to content
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

Implement event upcasting. #263

Merged
merged 13 commits into from
Mar 19, 2019
Merged

Conversation

trbngr
Copy link
Contributor

@trbngr trbngr commented Mar 16, 2019

A quick stab at #258

@slashdotdash
Copy link
Member

slashdotdash commented Mar 17, 2019

Thanks for the pull request, this looks like a good start.

It’s worth noting that events published to subscribers, such as event handlers and process managers, won’t go through the stream forward function. To solve this issue the Commanded.EventStore behaviour will need to be extended to allow a mapper function to be provided to both stream forward and subscribe to stream so that the upcasting can happen in both places. This likely requires changes to the in-memory adapter, Postgres event store adapter, and Greg Young’s Event Store (extreme) adapter. There’s quite a lot of coordination involved in changing all three of those so unless you’re feeling brave I can merge this PR as is and continue?

@trbngr
Copy link
Contributor Author

trbngr commented Mar 17, 2019

Thanks Ben. Good catch. I'd like to investigate this further before you merge it.

@trbngr
Copy link
Contributor Author

trbngr commented Mar 17, 2019

I think the latest commit addresses your concerns and will not required tweaking on the ES adapters.

As I believe this is commanded only feature, we should be good.

@trbngr
Copy link
Contributor Author

trbngr commented Mar 17, 2019

Oh! And I fixed a bug in the InMemory adapter. It was enuming over the stream and therefore executing the event_stream.

And apparently this broke some tests. :)

Fixing....

@trbngr
Copy link
Contributor Author

trbngr commented Mar 17, 2019

I wonder if stream_forward is the right place for the upcast. I'm thinking it should really be in Aggregate.handle_info({:events, events}, _) like the others.

Thoughts?

@slashdotdash
Copy link
Member

Aggregate.handle_info({:events, events}, _)

Is only used for transient subscriptions to the configured event store which means it will never receive historical events so no upcasting is required.

Having the upcast applied in stream_forward is useful because it allows consumers to read from the configured event store if they need to.

@slashdotdash
Copy link
Member

@trbngr Is this PR ready to merge now?

@trbngr
Copy link
Contributor Author

trbngr commented Mar 18, 2019

That's your call, bud. I am done with it

@slashdotdash slashdotdash merged commit 79814e8 into commanded:master Mar 19, 2019
slashdotdash added a commit that referenced this pull request Mar 19, 2019
@slashdotdash slashdotdash mentioned this pull request Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants