コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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));
        }
コード例 #3
0
ファイル: NtfsEventStore.cs プロジェクト: RichieYang/Cirqus
        internal NtfsEventStore(string basePath, bool dropEvents)
        {
            Directory.CreateDirectory(basePath);

            GlobalSequenceIndex = new GlobalSequenceIndex(basePath, dropEvents);
            DataStore = new DataStore(basePath, dropEvents);
            CommitLog = new CommitLog(basePath, dropEvents);
        }
コード例 #4
0
        public NtfsEventStore(string basePath, bool dropEvents)
        {
            Directory.CreateDirectory(basePath);

            GlobalSequenceIndex = new GlobalSequenceIndex(basePath, dropEvents);
            DataStore           = new DataStore(basePath, dropEvents);
            CommitLog           = new CommitLog(basePath, dropEvents);
        }
コード例 #5
0
 public void Dispose()
 {
     GlobalSequenceIndex.Dispose();
     CommitLog.Dispose();
 }