Can versions be skipped?

Is it possible for Event Store to return a series of events where a version # is skipped? Or is version purely a count of events in a stream?

It is an incrementing sequence.

That answer could fit either alternative I asked about.

Specifically, I am separating out metadata like Id and Version from the specific event payload to isolate domain concerns. I am wondering if I need to model the Version with the event payload or can I just use a simple count of events.

If GES can skip events, then I probably need to at least remember the last committed version, and can count up from there for the uncommitted before I write to stream. Otherwise, I can just do a total count of events as the version.

It does not skip.

After thinking about it, just to be safe, I ended up using last committed version, then the uncommitted events will count up from there. This is the EventStream that is passed from the handler to aggregate for replay/save. Event payloads are IEvent. Comments and snide remarks welcome.

public class EventStream

{

public string StreamId { get; private set; }

private readonly List _uncommitted = new List();

private readonly IEvent[] _committed;

public IEnumerable Uncommitted { get { return _uncommitted.AsEnumerable(); } }

public IEnumerable All { get { return _committed.Concat(_uncommitted); } }

public int CommittedVersion { get; private set; }

public void Append(IEvent message)

{

_uncommitted.Add(message);

}

public EventStream(string streamId, int committedVersion, IEnumerable committed)

{

StreamId = streamId;

CommittedVersion = committedVersion;

_committed = committed.ToArray();

}

}

If you want to use things like optimistic concurrency you need to use the event stores ifs anyways (eg the sequence in the stream). I’m not sure what you are passing in as committed version here…

Well, I was going to use the latest version as the committed version, then for each uncommitted event after the behavior ran, add 1. But now I’m thinking I don’t need either the ID or version for this. Those things will probably be in local scope for the handler anyway.

Committed version gets assigned internally.

Right my bad, I only need to read the last version so I can do optimistic concurrency and give an expected version on save.

Yep the rest will be sequenced automatically.