There is something not really easy to get right with Position/StreamPosition but maybe I’m missing something.
When calling ReadStreamAsync / ReadAllAsync the position passed is the position of the first event we’d like to receive.
For the first call, it’s ok, since we can pass 0 (Position.Start, StreamPosition.Start).
Now, lets say we read some events. We can get the position of the last one in the EventData. let’s call it P.
If we do a new read from position P, we get the event at position P again . The reader code has to protect against this duplicate.
It should be possible to either get P+1 (it’s doable for StreamPosition since it’s an incremental int, but not for Position), or to ask a ReadStreamAsync/ReadAllAsync starting after given position.
This would be especially usefull for snapshots. We’d be able to store the snapshot along the position of the last processed event, and the reads would then start after this position.
How do you manage this on your side ?