Esempio n. 1
0
        public EventStoreStatefulActorBuilder <TActor, TAggregate> WithReadManyStreamFromStartCache(
            string[] streamIds,
            IEventTypeProvider <TAggregate> eventTypeProvider = null,
            Action <MultipleStreamsCatchupCacheConfiguration <TAggregate> > getMultipleStreamsCatchupCacheConfiguration = null)
        {
            var getSubscribeFromEndMultipleStreamsEventStoreCache = new Func <IConnectionStatusMonitor <IEventStoreConnection>, ILoggerFactory, ISnapshotStore <TAggregate>, ISnapshotStrategy, IAggregateCache <TAggregate> >((connectionMonitor, loggerFactory, snapshotStore, snapshotStrategy) =>
            {
                var multipleStreamsCatchupCacheConfiguration = new MultipleStreamsCatchupCacheConfiguration <TAggregate>(streamIds)
                {
                    CrashAppIfSubscriptionFail = _actorConfiguration.CrashAppOnError
                };

                getMultipleStreamsCatchupCacheConfiguration?.Invoke(multipleStreamsCatchupCacheConfiguration);

                var multipleStreamsCatchupCache = new MultipleStreamsCatchupCache <TAggregate>(connectionMonitor, multipleStreamsCatchupCacheConfiguration, eventTypeProvider, loggerFactory, snapshotStore, snapshotStrategy);

                return(multipleStreamsCatchupCache);
            });

            if (null != _eventStoreActorConfiguration)
            {
                throw new InvalidOperationException("A cache as already been registered - only one cache allowed");
            }

            _eventStoreActorConfiguration = new EventStoreActorConfiguration <TAggregate>(_actorConfiguration, getSubscribeFromEndMultipleStreamsEventStoreCache);

            return(this);
        }
        public EventStoreStatefulActorBuilder <TActor, TAggregate, TRegistry> WithReadManyStreamsFromStartCache(
            string[] streamIds,
            IEventTypeProvider <TAggregate> eventTypeProvider,
            Action <MultipleStreamsCatchupCacheConfiguration <TAggregate> > getMultipleStreamsCatchupCacheConfiguration = null,
            ISnapshotStore <TAggregate> snapshotStore = null,
            ISnapshotStrategy snapshotStrategy        = null)
        {
            if (null != EventStoreCache)
            {
                throw new InvalidOperationException($"A cache has already been set => {EventStoreCache.GetType()}");
            }

            var multipleStreamsCatchupCacheConfiguration = new MultipleStreamsCatchupCacheConfiguration <TAggregate>(streamIds);

            getMultipleStreamsCatchupCacheConfiguration?.Invoke(multipleStreamsCatchupCacheConfiguration);

            EventStoreCache = new MultipleStreamsCatchupCache <TAggregate>(ConnectionMonitor, multipleStreamsCatchupCacheConfiguration, eventTypeProvider, LoggerFactory, snapshotStore, snapshotStrategy);

            return(this);
        }