Example #1
0
        private async Task <BatchIDGenerator> EnsureGenerator()
        {
            if (_idGenerator == null)
            {
                using (ITransaction tx = await _db.StartTransactionAsync()) {
                    Maybe <EventID> lastID = await _db
                                             .UseTransaction(tx)
                                             .GetCollection <RecordedEvent>(CollectionName)
                                             .Max <EventID>("_id");

                    _idGenerator = BatchIDGenerator.Create(lastID.OrDefault());
                }
            }

            return(_idGenerator);
        }
Example #2
0
 internal MongoEventStore(IMongoFacade db, EventStoreSettings settings, BatchIDGenerator idGenerator) : this(db, settings)
 {
     _idGenerator = idGenerator;
 }