Event sourcing (laracon online)

Event sourcing (laracon online)

A1b4b398630bbd32b77a82cbc37fae9a?s=128

Freek Van der Herten

March 06, 2019
Tweet

Transcript

  1. 2.

    About me Freek Van der Herten Partner & developer at

    Spatie @freekmurze https://murze.be https://ohdear.app
  2. 3.

    Spatie Since 2003 Websites, applications and webshops Team 9 awesome

    human beings Specialisation Laravel, front-end development
  3. 5.

    We create a lot of it ± 200 packages on

    Packagist ± 2,000,000 downloads a month ± 25,000,000 total downloads All Postcardware!
  4. 12.

    Traditional application Write data in database An update means overwriting

    the old data The old data cannot be accessed anymore
  5. 15.

    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. 22.
  7. 25.

    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
  8. 27.
  9. 29.

    Eventsauce Package made by Frank De Jonge Focuses on aggregates

    Framework agnostic Separate Laravel bindings package available Very powerful, adds complexity
  10. 34.

    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)
  11. 35.

    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
  12. 36.

    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
  13. 37.

    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
  14. 38.

    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
  15. 39.
  16. 41.

    Summary Laravel Event Projector Easy to use package to get

    started with projections Hooks into Laravel's native events Replay capabilities No aggregates
  17. 42.

    Summary EventSauce Framework agnostic Support for aggregates, process modelling No

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