// Special constructor for building from a cached instance internal EventStream(IEventStream clone, IBuilder builder, IStoreStreams store, ISnapshot snapshot) { _store = store; _snapshots = builder.Build <IStoreSnapshots>(); _oobHandler = builder.Build <IOobHandler>(); _builder = builder; Bucket = clone.Bucket; StreamId = clone.StreamId; _snapshot = snapshot; _committed = clone.Committed.ToList(); _uncommitted = new List <IWritableEvent>(); _outofband = new List <IWritableEvent>(); _pendingShot = null;; // Todo: this is a hack // Get the commit id of the current message because we need it to make writable events _commitId = builder?.Build <IUnitOfWork>().CommitId ?? Guid.Empty; // The commit version is calculated based on an existing snapshot. // If restoring from cache with a new snapshot, we'll remove committed events before the snapshot if (_snapshot != null && Committed.Any() && Committed.First().Descriptor.Version <= _snapshot.Version) { _committed = _committed.Where(x => x.Descriptor.Version > _snapshot.Version); } }
public EventStream(IBuilder builder, IStoreStreams store, string bucket, string streamId, IEnumerable <IWritableEvent> events, ISnapshot snapshot) { _store = store; _snapshots = builder?.Build <IStoreSnapshots>(); _oobHandler = builder?.Build <IOobHandler>(); _builder = builder; Bucket = bucket; StreamId = streamId; _committed = events?.ToList() ?? new List <IWritableEvent>(); _snapshot = snapshot; _uncommitted = new List <IWritableEvent>(); _outofband = new List <IWritableEvent>(); _pendingShots = new List <ISnapshot>(); }
// Special constructor for building from a cached instance internal EventStream(IEventStream clone, IBuilder builder, IStoreStreams store, ISnapshot snapshot) { _store = store; _snapshots = builder.Build <IStoreSnapshots>(); _oobHandler = builder.Build <IOobHandler>(); _builder = builder; Bucket = clone.Bucket; StreamId = clone.StreamId; _snapshot = snapshot; _committed = clone.Committed.ToList(); _uncommitted = new List <IWritableEvent>(); _outofband = new List <IWritableEvent>(); _pendingShots = new List <ISnapshot>(); if (_snapshot != null && Committed.Any() && Committed.First().Descriptor.Version <= _snapshot.Version) { _committed = _committed.Where(x => x.Descriptor.Version > _snapshot.Version); } }
public EventStream(IBuilder builder, IStoreStreams store, string streamType, string bucket, string streamId, IEnumerable <IWritableEvent> events, ISnapshot snapshot) { _store = store; _snapshots = builder?.Build <IStoreSnapshots>(); _oobHandler = builder?.Build <IOobHandler>(); _builder = builder; StreamType = streamType; Bucket = bucket; StreamId = streamId; _committed = events?.ToList() ?? new List <IWritableEvent>(); _snapshot = snapshot; _uncommitted = new List <IWritableEvent>(); _outofband = new List <IWritableEvent>(); _pendingShot = null; // Todo: this is a hack // Get the commit id of the current message because we need it to make writable events _commitId = builder?.Build <IUnitOfWork>().CommitId ?? Guid.Empty; }