public void Save(Guid batchId, IEnumerable <EventData> events) { lock (_lock) { var batch = events.ToList(); bool isCorrupted; var globalSequenceNumber = CommitLog.Read(out isCorrupted); if (isCorrupted) { CommitLog.Recover(); } GlobalSequenceIndex.DetectCorruptionAndRecover(DataStore, globalSequenceNumber); foreach (var domainEvent in batch) { domainEvent.Meta[DomainEvent.MetadataKeys.GlobalSequenceNumber] = (++globalSequenceNumber).ToString(Metadata.NumberCulture); domainEvent.Meta[DomainEvent.MetadataKeys.BatchId] = batchId.ToString(); } EventValidation.ValidateBatchIntegrity(batchId, batch); GlobalSequenceIndex.Write(batch); DataStore.Write(batchId, batch); CommitLog.Write(globalSequenceNumber); } }
public IEnumerable <EventData> Stream(long globalSequenceNumber = 0) { var lastCommittedGlobalSequenceNumber = CommitLog.Read(); return(from record in GlobalSequenceIndex.Read(lastCommittedGlobalSequenceNumber, offset: globalSequenceNumber) select DataStore.Read(record.AggregateRootId, record.LocalSequenceNumber)); }
internal NtfsEventStore(string basePath, bool dropEvents) { Directory.CreateDirectory(basePath); GlobalSequenceIndex = new GlobalSequenceIndex(basePath, dropEvents); DataStore = new DataStore(basePath, dropEvents); CommitLog = new CommitLog(basePath, dropEvents); }
public NtfsEventStore(string basePath, bool dropEvents) { Directory.CreateDirectory(basePath); GlobalSequenceIndex = new GlobalSequenceIndex(basePath, dropEvents); DataStore = new DataStore(basePath, dropEvents); CommitLog = new CommitLog(basePath, dropEvents); }
public void Dispose() { GlobalSequenceIndex.Dispose(); CommitLog.Dispose(); }