Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Event sourcing (laracon online)

Event sourcing (laracon online)

Freek Van der Herten

March 06, 2019
Tweet

More Decks by Freek Van der Herten

Other Decks in Programming

Transcript

  1. About me Freek Van der Herten Partner & developer at

    Spatie @freekmurze https://murze.be https://ohdear.app
  2. Spatie Since 2003 Websites, applications and webshops Team 9 awesome

    human beings Specialisation Laravel, front-end development
  3. We create a lot of it ± 200 packages on

    Packagist ± 2,000,000 downloads a month ± 25,000,000 total downloads All Postcardware!
  4. Traditional application Write data in database An update means overwriting

    the old data The old data cannot be accessed anymore
  5. Event Sourced Application The application will fire off events Events

    will get written in a dedicated store Events are passed to consumers that create projections Aggregate, Aggregate Root...
  6. Laravel Event Projector Package made by Spatie It's not full

    event sourcing, it focuses on projections Beautifully integrated into Laravel Easy to get started with
  7. Eventsauce Package made by Frank De Jonge Focuses on aggregates

    Framework agnostic Separate Laravel bindings package available Very powerful, adds complexity
  8. AGGREGATE ROOT REPOSITORY UUID PAYLOAD TIME APP Subtract $1000 RETRIEVE

    PERSIST Subtract $1000 AGGREGATE ROOT ACCOUNTS CONSUMER -$1000 ABC-123 Subtract 1000 11:12 AM (empty)
  9. AGGREGATE ROOT REPOSITORY UUID PAYLOAD TIME APP RETRIEVE PERSIST Subtract

    $750 AGGREGATE ROOT ACCOUNTS -$1000 CONSUMER ABC-123 Subtract 1000 11:12 AM Subtract $750 Subtract $1000
  10. AGGREGATE ROOT REPOSITORY UUID PAYLOAD TIME APP RETRIEVE PERSIST Subtract

    $750 AGGREGATE ROOT ACCOUNTS -$1750 CONSUMER ABC-123 Subtract 1000 11:12 AM Subtract $750 Subtract $1000 ABC-124 Subtract 750 01:17 PM
  11. AGGREGATE ROOT REPOSITORY UUID PAYLOAD TIME APP RETRIEVE PERSIST AGGREGATE

    ROOT ACCOUNTS -$1750 CONSUMER ABC-123 Subtract 1000 11:12 AM ABC-124 Subtract 750 01:17 PM Subtract $1250 Subtract $1000 Subtract $750 Subtract $1250 Propose loan
  12. AGGREGATE ROOT REPOSITORY ABC-123 Subtract 1000 11:12 AM ABC-124 Subtract

    750 01:17 PM ABC-125 Subtract 1250, Propose loan 05:51 PM UUID PAYLOAD TIME ACCOUNTS APP CONSUMER CONSUMER 2 PROPOSED LOANS Subtract $1250 -$3000 RETRIEVE PERSIST Subtract $1000 Subtract $750 Subtract $1250 Propose loan AGGREGATE ROOT
  13. Summary Laravel Event Projector Easy to use package to get

    started with projections Hooks into Laravel's native events Replay capabilities No aggregates
  14. Summary EventSauce Framework agnostic Support for aggregates, process modelling No

    replay capabilities out of the box https://github.com/spatie/laravel-eventsauce