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

Is it possible to access the created_at date of an event in apply()? #4

Closed
PJKerrigan opened this issue Nov 29, 2022 · 4 comments
Closed

Comments

@PJKerrigan
Copy link

PJKerrigan commented Nov 29, 2022

Forgive me if the answer to this question is obvious, I'm a beginner when it comes to Rust.

I'm looking at moving an event-sourced system using Laravel (via spatie/laravel-event-sourcing) to Rust, but there are differences between the libraries.

Is it possible to access the event metadata, particularly the date the event was created, inside of the aggregate's apply function?

@tqwewe
Copy link
Member

tqwewe commented Nov 29, 2022

That's a good question I haven't considered before. Currently there's no way to access event metadata in apply. One solution would be to store a timestamp in the event itself.

I'm actually in the process of rewriting thalo entirely, and have been working on it for a few weeks now. I'll try to push what I have soon to a different branch. For this reason though, I have to warn you that using Thalo currently wouldn't provide a lot since its missing a few things. You're better off waiting for me to push the rewrite, or look into another library for the time being. But if you are just playing around then it should be fine.

Does Laravel event sourcing support reading event metadata when applying events to an aggregate?

@PJKerrigan
Copy link
Author

Thanks for the response!

The PHP library I mentioned in my post does allow that. The events inherit from a specific class ShouldBeStored, which has the metadata assigned when they are recorded, before being handed to the aggregate apply method and then projectors and reactors.

I don't mind storing dates and so-on inside the events themselves, it's just quite useful for created_at/updated_at fields on projections.

I'll wait for the rewrite. This seems like a really cool project. 👍

@tqwewe
Copy link
Member

tqwewe commented Dec 7, 2022

Hey @PJKerrigan

I've pushed the rewrite under the runtime-rewrite branch!
I'm pretty happy with how things have turned out, though building the examples requires a few steps since wasm components are still very eary stage.

Let me know if you have any questions if you decide to try it out, I'd love to help you with it. Or if you've joined the Discord, feel free to send a message there.

@tqwewe
Copy link
Member

tqwewe commented Dec 8, 2022

Closing for now as the rewrite allows for this information and has been merged to main

@tqwewe tqwewe closed this as completed Dec 8, 2022
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

No branches or pull requests

2 participants