altairsix / eventsource

Serverless Go event sourcing library built on top of dynamodb
247 stars 39 forks source link

err from loadVersion should not be discarded in Apply #19

Open metaleap opened 2 years ago

metaleap commented 2 years ago

Culprit: https://github.com/altairsix/eventsource/blob/7b6859b7a00908296beea99d5d2800b6c071c084/repository.go#L187

loadVersion can fail for reasons other than "not found", such as "store implementation has connectivity outage" etc. You do not want to discard such errs and fall back on a newly-instantiated empty aggregate here...

A fix to this would do so only for errs of type eventsource.Error with a Code() of eventsource.ErrAggregateNotFound I reckon? --- with all other errs being properly returned immediately.