public void Configure(IEventBus eventBus, IAggregateCache aggregateCache) { _eventBus = eventBus; _registeredAggregateCaches.Add(aggregateCache); eventBus.Subscribe((AggregateCacheCleared e) => aggregateCache.Clear(e.SerializedAggregateId, e.AggregateType)); }
public async Task ShouldSuccesfullyPersistAndHydrateEventsFromAggregate() { // ARRANGE var testAggregate = new TestAggregate(Guid.NewGuid()); //var eventRepository = new SqlServerEventRepository("Server=tcp:shuffle.database.windows.net,1433;Initial Catalog=Shuffle;Persist Security Info=False;User ID=kvinther;Password=k1617v_KV;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;Application Name=Shuffle;"); var eventRepository = new SqlServerEventRepository("Server=.\\sqlexpress;Initial Catalog=VerdunEvents;Persist Security Info=False;Trusted_Connection=True;MultipleActiveResultSets=False;Connection Timeout=30;Application Name=Shuffle;"); var aggregateFactory = new DefaultAggregateFactory(); var repository = new AggregateRepository(eventRepository, aggregateFactory); var listener = new BasicEventListener(); IAggregateCache cache = null; //cache = new RedisAggregateCache("shuffle.redis.cache.windows.net:6380,password=z0cYd5K7aNjtE9tl8x6nxYa2lK5TwrJcB1aHsZGCx5Q=,ssl=True,abortConnect=False"); cache = new RedisAggregateCache("localhost"); var store = new AggregateStore(repository, listener, aggregateCache: cache); // ACT var now = DateTime.Now; for (var i = 1; i <= 50; i++) { testAggregate.PublishTestEvent($"{i}"); await store.Save(testAggregate); var hydratedTestAggregate = store.GetById <TestAggregate>(testAggregate.Id); // ASSERT Assert.AreEqual(testAggregate.Id, hydratedTestAggregate.Id); Assert.AreEqual(testAggregate.Version, hydratedTestAggregate.Version); Assert.AreEqual(testAggregate.State, hydratedTestAggregate.State); } Debug.WriteLine($"Total time: {(DateTime.Now - now):g}"); }
public CachingRepository(IRepository baseRepository, Func <IRepository, IAggregateCache> cacheFactory = null) { if (cacheFactory == null) { cacheFactory = repo => new ReadThroughAggregateCache(repo); } _cache = cacheFactory(baseRepository); }
public CorrelatedStreamStoreRepository( IRepository repository, Func <IRepository, IAggregateCache> cacheFactory = null) { _repository = repository; if (cacheFactory != null) { _cache = cacheFactory(_repository); } }
public CorrelatedStreamStoreRepository( IStreamNameBuilder streamNameBuilder, IStreamStoreConnection streamStoreConnection, IEventSerializer eventSerializer, Func <IRepository, IAggregateCache> cacheFactory = null) { _repository = new StreamStoreRepository(streamNameBuilder, streamStoreConnection, eventSerializer); if (cacheFactory != null) { _cache = cacheFactory(_repository); } }
public AggregateStore( IAggregateRepository aggregateRepository, IEventListener eventListener, IAggregateTracking aggregateTracking = null, IAggregateCache aggregateCache = null) { if (aggregateRepository == null) { throw new ArgumentNullException(nameof(aggregateRepository)); } if (eventListener == null) { throw new ArgumentNullException(nameof(eventListener)); } _aggregateRepository = aggregateRepository; _aggregateTracking = aggregateTracking; _eventListener = eventListener; _aggregateCache = aggregateCache; }
public TestCatchupWithMailboxActor(IActorConfiguration actorConfiguration, IAggregateCache <SomeDataAggregate> eventStoreCache, ILoggerFactory loggerFactory = null) : base(actorConfiguration, eventStoreCache, loggerFactory) { }
public TestStatefulActorOneHealthChecksMvc(IActorConfiguration actorConfiguration, IAggregateCache <SomeDataAggregate> eventStoreCache, ILoggerFactory loggerFactory = null) : base(actorConfiguration, eventStoreCache, loggerFactory) { }
public EventCountStatefulActor(IActorConfiguration actorConfiguration, IAggregateCache <EventCountAggregate> eventStoreCache, ILoggerFactory loggerFactory = null) : base(actorConfiguration, eventStoreCache, loggerFactory) { }
public TradeSink(IActorConfiguration actorConfiguration, IAggregateCache <Trade> eventStoreCache, ILoggerFactory loggerFactory = null) : base(actorConfiguration, eventStoreCache, loggerFactory) { }
public TestErrorHandlingStatefulActor(IActorConfiguration actorConfiguration, IAggregateCache <SomeDataAggregate> eventStoreCache, ILoggerFactory loggerFactory = null) : base(actorConfiguration, eventStoreCache, loggerFactory) { }
public UserRepository(IEventStore eventStore, IAggregateCache <Aggregates.User> cache) : base(eventStore, cache) { }
public AggregateRepository(IEventStore eventStore, IAggregateCache <TAggregate> cache) { EventStore = eventStore; Cache = cache; }
public TestBusRegistrationEventStoreStatefullActorMvc(IActorConfiguration actorConfiguration, IAggregateCache <SomeDataAggregate> eventStoreCache, ILoggerFactory loggerFactory = null) : base(actorConfiguration, eventStoreCache, loggerFactory) { }
public TestAggregatedActorTwo(IActorConfiguration actorConfiguration, IAggregateCache <SomeDataAggregate> eventStoreCache, ILoggerFactory loggerFactory = null) : base(actorConfiguration, eventStoreCache, loggerFactory) { }
public BaseEventStoreStatefulActor(IActorConfiguration actorConfiguration, IAggregateCache <TAggregate> eventStoreCache, ILoggerFactory?loggerFactory = null) : base(actorConfiguration, loggerFactory) { State = eventStoreCache; Initialize(); }