public bool TryGetLastValue(out StreamId lastValue)
        {
            var lastEventNumber = _indexReader.GetStreamLastEventNumber(LogV3SystemStreams.StreamsCreatedStreamNumber);
            var success         = ExpectedVersion.NoStream < lastEventNumber && lastEventNumber != EventNumber.DeletedStream;

            lastValue = StreamIdConverter.ToStreamId(lastEventNumber);
            return(success);
        }
Example #2
0
        private void CheckStreamVersion(string streamId, int newEventNumber, CommitLogRecord commit)
        {
            if (newEventNumber == EventNumber.DeletedStream)
            {
                return;
            }

            int lastEventNumber = _indexReader.GetStreamLastEventNumber(streamId);

            if (newEventNumber != lastEventNumber + 1)
            {
                if (Debugger.IsAttached)
                {
                    Debugger.Break();
                }
                else
                {
                    throw new Exception(
                              string.Format("Commit invariant violation: new event number {0} doesn't correspond to current stream version {1}.\n"
                                            + "Stream ID: {2}.\nCommit: {3}.", newEventNumber, lastEventNumber, streamId, commit));
                }
            }
        }
Example #3
0
 bool IReadIndex.IsStreamDeleted(string streamId)
 {
     return(_indexReader.GetStreamLastEventNumber(streamId) == EventNumber.DeletedStream);
 }