spatie / larabank-projectors

Larabank built with projectors
https://spatie.be/docs/laravel-event-sourcing
70 stars 14 forks source link

CreateWithAttributes method will fail #21

Closed chmoelders closed 3 years ago

chmoelders commented 3 years ago

Hi Spatie-Team!

Thank you for the great packages and examples related to event-sourcing!

I assume the lines below does only work if the queue driver is set to sync or if you have a very fast or empty queue, otherwise the account isn't persisted and uuid() will return null. Isn't it?

https://github.com/spatie/larabank-projectors/blob/master/app/Account.php#L18-L34

Can you please show me your preferred way to create an instance.

freekmurze commented 3 years ago

$uuid will always contain a value, even if you have slow queues.

To know more about event sourcing, consider picking up our upcoming course: https://event-sourcing-laravel.com

chmoelders commented 3 years ago

How can that be?

If AccountsProjector::onAccountCreated(AccountCreated $event) hasn't handled the event, there we will not be an Account with the given UUID in the database table.

Thank you for the Link to the course. I'm already registered for the newsletter a while.

freekmurze commented 3 years ago

How can that be?

Ah, you're right, this example assumes that this is being performed in sync