Skip to content

Instantly share code, notes, and snippets.

@Richard87
Last active September 24, 2021 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Richard87/0832bb971b6330edf1a0b452e09dddbb to your computer and use it in GitHub Desktop.
Save Richard87/0832bb971b6330edf1a0b452e09dddbb to your computer and use it in GitHub Desktop.
Event sourcing Thoughts

Event sourcing Thoughts

Smart DDD People

  • Vaughn Vernon
  • Eric Evans
  • Martin Fowler
  • Greg Young
  • Mathias Verraes
  • Mauro Serventi
  • Freek Van Der Herten
  • Frank de Jonge
  • Marco Pivetta @Ocramius
  • Matthias Noback

FAQ

Difference between Commands, Domain Events and Side Effects, how to describe then in code? F.eks Sending an email after a UserRegistered domain event.

Methods in aggregates that trigger events/state change is called Commands, if it is successfull / meets all Domain rules, it raises (Domain) Events. Projections listen to events to build itself, Reactors listens to events to send emails / trigger behaviour outside the domain. Store all events, when replying old events, trigger all event listeners that changes state, but never Reactors/Sagas/ProcessManagers who's purpose is to send trigger new events.

A business rule that crosses aggregates. I would like to avoid allowing adding a Product to a Order if there is no more stock. How can I check "if (!product->isInStock()) inside of Order agregate? (I assume Product is its own aggregate inside the same bounded context)

All communications should be based on Events. when a Products stock is changed, a event should be thrown and picked up in Order agregate, that saves the state in its own projection. Then that data can be used when handling future commands.

Can a aggregate use state from its projections, or is projections only for getting data out of the bounded context?

What is the difference between a Aggregate's state, and a Domain Context Projection?

Can a aggregate use data from the "outside" as long as it's not relevant for the business rules (what if it changes)?

Raising events and throwing exceptions at once?

How should you migrate when different versions of the app is running at the same time? (each copy of the app could use its own projections database and migrate? But use the same event store)

Kurs

https://spatie.be/docs/laravel-event-sourcing/v5/introduction

Lesestoff:

Bøker:

Filmer

Example Repos:

SKIL ePortal

Vi trenger en Command Queue for å dispatche synkrone, og asynkrone kommandoer. DomainEvents av fullførte kommandoer.

  • Legacy Domain
    • Nye UserRegistered(id, name, email) og UserChangedName(id, name) event
    • Nye OfficeRegistered(id, name) og OfficeNameChanged(id, name)
    • HelfoUserRegistered, HelfoUserUpdated
  • PraksisNett Domain
    • Aggregates
      • Project Aggregate Root
      • Participant Aggregate Root
        • Snowbox details?
    • Events
      • ProjectCreated, ProjectUpdated, SnowboxUpdated
      • ParticipantAdded
    • Projections:
      • Projects
      • Participants (with User, HPR, Snowbox details)

Infrastructure

  • Dispatch Commands
  • Collect and store Domain Events
  • Restore Aggregate from DomainEvets
  • Event Store (id, aggregate root id, domain, event name, payload, timestamp, metadata)
  • Projections (subscribed events, last event used)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment