Ejemplo n.º 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);
        }
Ejemplo n.º 2
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 void AddConfiguration <TActor, TAggregate>(IEventStoreActorConfiguration <TAggregate> eventStoreActorConfiguration)
     where TActor : IStatefulActor <TAggregate>
     where TAggregate : IAggregate, new()
 {
     _eventStoreCaches.Add(typeof(TActor), eventStoreActorConfiguration);
 }