Пример #1
0
        public EventStoreStatefulActorBuilder <TActor, TAggregate> WithReadAllFromEndCache(
            IEventTypeProvider <TAggregate> eventTypeProvider = null,
            Action <AllStreamsCatchupCacheConfiguration <TAggregate> > volatileCacheConfigurationBuilder = null)
        {
            var getSubscribeFromEndEventStoreCache = new Func <IConnectionStatusMonitor <IEventStoreConnection>, ILoggerFactory, ISnapshotStore <TAggregate>, ISnapshotStrategy, IAggregateCache <TAggregate> >((connectionMonitor, loggerFactory, snapshotStore, snapshotStrategy) =>
            {
                var subscribeFromEndCacheConfiguration = new AllStreamsCatchupCacheConfiguration <TAggregate>(Position.End)
                {
                    CrashAppIfSubscriptionFail = _actorConfiguration.CrashAppOnError
                };

                volatileCacheConfigurationBuilder?.Invoke(subscribeFromEndCacheConfiguration);

                var eventProvider = eventTypeProvider ?? new ConsumerBasedEventProvider <TAggregate, TActor>();

                var subscribeFromEndEventStoreCache = new AllStreamsCatchupCache <TAggregate>(connectionMonitor,
                                                                                              subscribeFromEndCacheConfiguration,
                                                                                              eventProvider, loggerFactory);

                return(subscribeFromEndEventStoreCache);
            });

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

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


            return(this);
        }
        public EventStoreStatefulActorBuilder <TActor, TAggregate, TRegistry> WithReadAllFromEndCache(
            IEventTypeProvider <TAggregate> eventTypeProvider,
            Action <AllStreamsCatchupCacheConfiguration <TAggregate> > getSubscribeFromEndCacheConfiguration = null)
        {
            if (null != EventStoreCache)
            {
                throw new InvalidOperationException($"A cache has already been set => {EventStoreCache.GetType()}");
            }

            var subscribeFromEndCacheConfiguration = new AllStreamsCatchupCacheConfiguration <TAggregate>(Position.End);

            getSubscribeFromEndCacheConfiguration?.Invoke(subscribeFromEndCacheConfiguration);

            EventStoreCache = new AllStreamsCatchupCache <TAggregate>(ConnectionMonitor, subscribeFromEndCacheConfiguration, eventTypeProvider, LoggerFactory);

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

            var catchupEventStoreCacheConfiguration = new AllStreamsCatchupCacheConfiguration <TAggregate>(Position.Start);

            getCatchupEventStoreCacheConfigurationBuilder?.Invoke(catchupEventStoreCacheConfiguration);

            EventStoreCache = new AllStreamsCatchupCache <TAggregate>(ConnectionMonitor, catchupEventStoreCacheConfiguration, eventTypeProvider, LoggerFactory, snapshotStore, snapshotStrategy);

            return(this);
        }