Beispiel #1
0
        // 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);
            }
        }
 internal UsingInitializedSnapshotStore(Boolean replaceExisting, Boolean async)
 {
     SnapshotStore = new SqlSnapshotStore(new SqlSnapshotStoreDialect(SqlServerConnection.Name), new BinarySerializer(), new SnapshotStoreSettings {
         Async = async, ReplaceExisting = replaceExisting
     });
     SnapshotStore.Purge();
 }
 public ResolveWeaklyConflictResolver(IStoreSnapshots snapstore, IStoreEvents eventstore, IDelayedChannel delay, StreamIdGenerator streamGen)
 {
     _snapstore  = snapstore;
     _eventstore = eventstore;
     _delay      = delay;
     _streamGen  = streamGen;
 }
 public StoreEntities(IMetrics metrics, IStoreEvents eventstore, IStoreSnapshots snapstore, IOobWriter oobstore, IEventFactory factory)
 {
     _metrics    = metrics;
     _eventstore = eventstore;
     _snapstore  = snapstore;
     _oobstore   = oobstore;
     _factory    = factory;
 }
 public CommandDispatcherFactory(
     IStoreEvents events,
     IStoreSnapshots snapshots
     )
 {
     _events    = events;
     _snapshots = snapshots;
 }
Beispiel #6
0
 public EntityRepository(TAggregateId aggregateId, IEventStream parentStream, IBuilder builder)
     : base(builder)
 {
     _aggregateId  = aggregateId;
     _parentStream = parentStream;
     _builder      = builder;
     _store        = _builder.Build <IStoreEvents>();
     _snapstore    = _builder.Build <IStoreSnapshots>();
 }
 public StoreEntities(IMetrics metrics, IStoreEvents eventstore, IStoreSnapshots snapstore, IOobWriter oobstore, IEventFactory factory, IVersionRegistrar registrar)
 {
     _metrics    = metrics;
     _eventstore = eventstore;
     _snapstore  = snapstore;
     _oobstore   = oobstore;
     _factory    = factory;
     _registrar  = registrar;
 }
Beispiel #8
0
 public RepositoryFactory(IMetrics metrics, IStoreEvents eventstore, IStoreSnapshots snapstore, IStorePocos pocostore, IOobWriter oobStore, IEventFactory factory)
 {
     _metrics    = metrics;
     _eventstore = eventstore;
     _snapstore  = snapstore;
     _pocostore  = pocostore;
     _oobStore   = oobStore;
     _factory    = factory;
 }
 public StoreEvents(IEventStoreConnection client, IBuilder builder, IMessageMapper mapper, IStoreSnapshots snapshots, ReadOnlySettings nsbSettings, IStreamCache cache)
 {
     _client      = client;
     _mapper      = mapper;
     _snapshots   = snapshots;
     _nsbSettings = nsbSettings;
     _builder     = builder;
     _cache       = cache;
     _shouldCache = _nsbSettings.Get <Boolean>("ShouldCacheEntities");
 }
 public StoreEntities(IMetrics metrics, IStoreEvents eventStore, IStoreSnapshots snapStore, IOobWriter oobStore, IEventFactory factory, IVersionRegistrar registrar, ITrackChildren childTracker)
 {
     _metrics      = metrics;
     _eventStore   = eventStore;
     _snapStore    = snapStore;
     _oobStore     = oobStore;
     _factory      = factory;
     _registrar    = registrar;
     _childTracker = childTracker;
 }
 public CommandDispatcher(
     IStoreEvents events,
     IStoreSnapshots snapshots,
     object command
     )
 {
     _events    = events;
     _snapshots = snapshots;
     _command   = command;
 }
Beispiel #12
0
 public CommandHandler(
     IStoreEvents events,
     IStoreSnapshots snapshots,
     string identity
     )
 {
     _events    = events;
     _snapshots = snapshots;
     _identity  = identity;
 }
Beispiel #13
0
 public StoreStreams(ICache cache, IStoreEvents store, IMessagePublisher publisher, IStoreSnapshots snapstore, StreamIdGenerator streamGen, IEnumerable <IEventMutator> mutators)
 {
     _cache     = cache;
     _store     = store;
     _publisher = publisher;
     _snapstore = snapstore;
     _streamGen = streamGen;
     _mutators  = mutators;
     _random    = new Random();
 }
        /// <summary>
        /// Initializes a new instance of <see cref="AggregateStore"/> using the specified <paramref name="settings"/>.
        /// </summary>
        internal AggregateStore(IApplyEvents aggregateUpdater, IStoreSnapshots snapshotStore, IStoreEvents eventStore, IStoreAggregateSettings settings)
        {
            Verify.NotNull(settings, nameof(settings));
            Verify.NotNull(eventStore, nameof(eventStore));
            Verify.NotNull(snapshotStore, nameof(snapshotStore));
            Verify.NotNull(aggregateUpdater, nameof(aggregateUpdater));

            this.snapshotInterval = settings.SnapshotInterval;
            this.aggregateUpdater = aggregateUpdater;
            this.snapshotStore = snapshotStore;
            this.eventStore = eventStore;
        }
        /// <summary>
        /// Initializes a new instance of <see cref="AggregateStore"/> using the specified <paramref name="settings"/>.
        /// </summary>
        internal AggregateStore(IApplyEvents aggregateUpdater, IStoreSnapshots snapshotStore, IStoreEvents eventStore, IStoreAggregateSettings settings)
        {
            Verify.NotNull(settings, nameof(settings));
            Verify.NotNull(eventStore, nameof(eventStore));
            Verify.NotNull(snapshotStore, nameof(snapshotStore));
            Verify.NotNull(aggregateUpdater, nameof(aggregateUpdater));

            this.snapshotInterval = settings.SnapshotInterval;
            this.aggregateUpdater = aggregateUpdater;
            this.snapshotStore    = snapshotStore;
            this.eventStore       = eventStore;
        }
Beispiel #16
0
        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>();
        }
Beispiel #17
0
        public Repository(IBuilder builder)
        {
            _builder       = builder;
            _snapstore     = _builder.Build <IStoreSnapshots>();
            _store         = _builder.Build <IStoreStreams>();
            _settings      = _builder.Build <ReadOnlySettings>();
            _store.Builder = _builder;

            // Conflict resolution is strong by default
            if (_conflictResolution == null)
            {
                _conflictResolution = (OptimisticConcurrencyAttribute)Attribute.GetCustomAttribute(typeof(T), typeof(OptimisticConcurrencyAttribute))
                                      ?? new OptimisticConcurrencyAttribute(ConcurrencyConflict.ResolveStrongly);
            }
        }
Beispiel #18
0
        public EventStream(IBuilder builder, IStoreEvents store, IStoreSnapshots snapshots, String bucket, String streamId, Int32 streamVersion, IEnumerable <IWritableEvent> events)
        {
            this._store         = store;
            this._snapshots     = snapshots;
            this._builder       = builder;
            this.Bucket         = bucket;
            this.StreamId       = streamId;
            this._streamVersion = streamVersion;
            this._version       = streamVersion;
            this._committed     = events.ToList();
            this._uncommitted   = new List <IWritableEvent>();
            this._pendingShots  = new List <ISnapshot>();
            this._children      = new Dictionary <String, IEventStream>();

            if (events == null || events.Count() == 0)
            {
                return;
            }
        }
Beispiel #19
0
        // 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);
            }
        }
Beispiel #20
0
        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;
        }
Beispiel #21
0
 public Repository(TParent parent, IMetrics metrics, IStoreEvents store, IStoreSnapshots snapshots, IOobWriter oobStore, IEventFactory factory, IDomainUnitOfWork uow)
     : base(metrics, store, snapshots, oobStore, factory, uow)
 {
     _parent = parent;
 }
Beispiel #22
0
 /// <summary>
 /// Initalizes a new isntance of <see cref="BenchmarkedSnapshotStore"/>.
 /// </summary>
 /// <param name="snapshotStore">The snapshot store to decorate.</param>
 /// <param name="statistics">The statistics class.</param>
 public BenchmarkedSnapshotStore(IStoreSnapshots snapshotStore, Statistics statistics)
 {
     this.snapshotStore = snapshotStore;
     this.statistics    = statistics;
 }
 /// <summary>
 /// Initalizes a new isntance of <see cref="BenchmarkedSnapshotStore"/>.
 /// </summary>
 /// <param name="snapshotStore">The snapshot store to decorate.</param>
 /// <param name="statistics">The statistics class.</param>
 public BenchmarkedSnapshotStore(IStoreSnapshots snapshotStore, Statistics statistics)
 {
     this.snapshotStore = snapshotStore;
     this.statistics = statistics;
 }
 public ResolveStronglyConflictResolver(IStoreSnapshots snapshot, IStoreEvents eventstore, StreamIdGenerator streamGen)
 {
     _snapstore  = snapshot;
     _eventstore = eventstore;
     _streamGen  = streamGen;
 }
 internal UsingInitializedSnapshotStore(Boolean replaceExisting, Boolean async)
 {
     SnapshotStore = new SqlSnapshotStore(new SqlSnapshotStoreDialect(SqlServerConnection.Name), new BinarySerializer(), new SnapshotStoreSettings { Async = async, ReplaceExisting = replaceExisting });
     SnapshotStore.Purge();
 }
Beispiel #26
0
 public Repository(IBuilder builder)
 {
     _builder   = builder;
     _store     = _builder.Build <IStoreEvents>();
     _snapstore = _builder.Build <IStoreSnapshots>();
 }
Beispiel #27
0
 public StoreEntities()
 {
     Snapstore = Fake <IStoreSnapshots>();
     A.CallTo(() => Snapstore.GetSnapshot <FakeEntity>(A <string> .Ignored, A <Id> .Ignored, A <Id[]> .Ignored)).Returns(Task.FromResult((ISnapshot)null));
     Inject(Snapstore);
 }
 /// <summary>
 /// Initializes a new instance of <see cref="AggregateStore"/>.
 /// </summary>
 public AggregateStore(IApplyEvents aggregateUpdater, IStoreSnapshots snapshotStore, IStoreEvents eventStore)
     : this(aggregateUpdater, snapshotStore, eventStore, Settings.Default.AggregateStore)
 {
 }
 /// <summary>
 /// Initializes a new instance of <see cref="AggregateStore"/>.
 /// </summary>
 public AggregateStore(IApplyEvents aggregateUpdater, IStoreSnapshots snapshotStore, IStoreEvents eventStore)
     : this(aggregateUpdater, snapshotStore, eventStore, Settings.Default.AggregateStore)
 {
 }