Hi Guys,
The ReadAllEventsForward method returns a slice which is represented by an array of events and a Position.
As far as I understand the Position is actually a position of the end of the slice: the position of the latest event in it.
Is it correct and safe to assume that the position of the second last event is Position.CommitPosition-1, third last event is Position.CommitPosition-2, etc?
Cheers,
Alexey.
Yuriy,
Thanks for the explanation.
Reading from AllEvents is exactly what I am trying to do. Will these changes in the dev branch provide me with the position of each even in the slice?
BTW, it would be nice if SubscribeToAll could have a Position as a parameter so it would mean “In my subscription I want to see all the messages starting from this position and further as they appear until I cancel the subscription”.
Cheers,
Alexey.
Alex,
Both reading from all and subscription to all with provide each event with position in a form that can be passed to read from all. However, subscriptions are to deliver events immediately when they are committed to the ES. So, to get events starting from a given position you need to read them from them position. With new release this will deliver you events in the same form as subscription does, so it will not be hard to switch to subscription when you reach the end of the $all stream.
Note that both $all stream and events delivered via subscription to all ordered the way that:
E2 goes after E1 means
E2.commit_positin > E1.commit_position || ( e2.commit_position == e1.commit_position && e2.prepare_position > e1.prepapre_position)
This comparison should be enough to find out whether you have already processed an event when switching from reading the all stream to receiving events from a subscription.
-yuriy