Is there a technical limitation for not having expected version control within Projections?


I would like to know why we can’t pass an expected version value when using emit. Is this due to some technical limitation?

Thank you for your time.

hmm this is a good question…

And one I do not have an immediate answer on.

As an exercise, I decided to have a look. It turns out EmittedStream 1 does a fair bit of checking before those emitted events got persisted. Some of those checks are:

  • If the targetted stream hasn’t been written from the outside

  • If another projection isn’t writing in the same stream.

I don’t understand how by reading the last event of the targetted stream, we prevent those conflicts from happening, considering reads are eventually consistent.

To my poor understanding, supporting expected version control at that level will complexify the code a lot for very few benefits. One question remains, are those checks in EmittedStream needed?

If we allow expected version value in emit, we let the user be responsible for conflicts while decreasing the amount of code in EmittedStream. What do you think?

As a side note, I didn’t know projections are not supposed to emit events that target the same stream, it should be mentioned in the documentation somewhere