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

Events triggering actions #2

Open
DomHudson opened this issue Nov 9, 2018 · 2 comments
Open

Events triggering actions #2

DomHudson opened this issue Nov 9, 2018 · 2 comments

Comments

@DomHudson
Copy link

Hi thanks for the example implementation, I'm enjoying looking at it.
In event_handler.py I noticed that the event is triggering the corresponding action; for example a post_created_event triggers the creation of the post.

My understanding was that the event should represent something that has happened already? My plan for implementing something similar was to perform the action first and then save the corresponding event.

For example my action might be CreatePost and once the post is created I then store a PostCreatedEvent.

What do you think of this? Would be good to get your views!

Many thanks,
Dom

@Dineshs91
Copy link
Owner

Dineshs91 commented Nov 10, 2018

@DomHudson If we create the post first, and then create the event, this might get us to an inconsistent state.

In the implementation I've done

  1. Event is created first
  2. Actual data is created after the event.

So if there is an issue creating the data, I can replay the events to get the data to a proper consistent state.

But if I create the object first and then the event, if the event creation fails then there is a chance of inconsistency, as replaying the events would miss out this data (Since storing this event failed).

Think of this as how postgres uses WAL https://en.wikipedia.org/wiki/Write-ahead_logging

@gpietro
Copy link

gpietro commented Sep 24, 2019

What if you want to reprocess the events to restore the state on a certain date and time or create different view models?

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

3 participants