public static EventStoreStatefulActorBuilder <TActor, TAggregate, TRegistry> Create( ClusterVNode clusterVNode, ConnectionSettings connectionSettings, IActorConfiguration actorConfiguration, ILoggerFactory?loggerFactory = null, Action <IEventStoreRepositoryConfiguration>?eventStoreRepositoryConfigurationBuilder = null) { var connection = EmbeddedEventStoreConnection.Create(clusterVNode, connectionSettings); var connectionMonitor = new EventStoreConnectionStatusMonitor(connection, loggerFactory); loggerFactory ??= new DummyLoggerFactory(); var eventStoreRepositoryConfiguration = new EventStoreRepositoryConfiguration(); eventStoreRepositoryConfigurationBuilder?.Invoke(eventStoreRepositoryConfiguration); var eventStoreRepository = new EventStoreAggregateRepository( eventStoreRepositoryConfiguration, connection, connectionMonitor, loggerFactory); var builder = new EventStoreStatefulActorBuilder <TActor, TAggregate, TRegistry>(actorConfiguration, eventStoreRepository, connectionMonitor, loggerFactory); return(builder); }
public static void Run() { var eventTypeProvider = new DefaultEventTypeProvider <EventCountAggregate>(() => new[] { typeof(EventCountOne), typeof(EventCountTwo) });; var fileSystemSnapshotProvider = new FileSystemSnapshotProvider <EventCountAggregate>(); var defaultSnapshotStrategy = new DefaultSnapshotStrategy(5); var eventCountActorWithSnapshot = EventStoreStatefulActorBuilder <EventCountStatefulActor, EventCountAggregate, DemoSystemRegistry> .Create(StaticData.EventStoreUrl, Do.GetConnectionSettings(), ActorConfiguration.Default) .WithReadOneStreamFromStartCache(StaticData.EntityOne, eventTypeProvider: eventTypeProvider, getMultipleStreamsCatchupCacheConfiguration: builder => { builder.KeepAppliedEventsOnAggregate = true; }, snapshotStore: fileSystemSnapshotProvider, snapshotStrategy: defaultSnapshotStrategy) .Build(); var eventCountActor = EventStoreStatefulActorBuilder <EventCountStatefulActor, EventCountAggregate, DemoSystemRegistry> .Create(StaticData.EventStoreUrl, Do.GetConnectionSettings(), ActorConfiguration.Default) .WithReadOneStreamFromStartCache(StaticData.EntityOne, eventTypeProvider: eventTypeProvider, getMultipleStreamsCatchupCacheConfiguration: builder => { builder.KeepAppliedEventsOnAggregate = true; }) .Build(); Do.Run(eventCountActor, eventCountActorWithSnapshot); }
public static void Run() { var eventTypeProvider = new DefaultEventTypeProvider <EventCountAggregate>(() => new[] { typeof(EventCountOne), typeof(EventCountTwo) });; var eventCountActor = EventStoreStatefulActorBuilder <EventCountStatefulActor, EventCountAggregate, DemoSystemRegistry> .Create(StaticData.EventStoreUrl, Do.GetConnectionSettings(), ActorConfiguration.Default) .WithReadManyStreamsFromStartCache( new[] { StaticData.EntityOne, StaticData.EntityTwo, StaticData.EntityThree }, eventTypeProvider: eventTypeProvider, getMultipleStreamsCatchupCacheConfiguration: builder => builder.KeepAppliedEventsOnAggregate = true) .Build(); Do.Run(eventCountActor); }
public async Task ShouldRunAnIntegrationScenario() { var url = new Uri("tcp://*****:*****@localhost:1113"); var userCredentials = new UserCredentials("admin", "changeit"); var connectionSettings = ConnectionSettings.Create() .UseDebugLogger() .DisableTls() .SetDefaultUserCredentials(userCredentials) .KeepRetrying() .Build(); var defaultEventTypeProvider = new DefaultEventTypeProvider <CurrencyPair>(() => new[] { typeof(CurrencyPairPriceChanged), typeof(CurrencyPairStateChanged) }); var traderOne = EventStoreStatefulActorBuilder <Trader, CurrencyPair, TestRegistry> .Create(url, connectionSettings, ActorConfiguration.Default) .WithReadAllFromStartCache(eventTypeProvider: defaultEventTypeProvider, getCatchupEventStoreCacheConfigurationBuilder: (configuration) => configuration.KeepAppliedEventsOnAggregate = true) .Build(); await Task.Delay(2000); Assert.IsTrue(traderOne.State.IsConnected); var traderTwo = EventStoreStatefulActorBuilder <Trader, CurrencyPair, TestRegistry> .Create(url, connectionSettings, ActorConfiguration.Default) .WithReadAllFromStartCache(eventTypeProvider: defaultEventTypeProvider, getCatchupEventStoreCacheConfigurationBuilder: (configuration) => configuration.KeepAppliedEventsOnAggregate = true) .Build(); await Task.Delay(500); Assert.IsTrue(traderTwo.State.IsConnected); await Task.Delay(4000); var eurodolOne = traderOne.State.GetCurrent("EUR/USD"); var eurodolTwo = traderTwo.State.GetCurrent("EUR/USD"); var chunnelOne = traderOne.State.GetCurrent("EUR/GBP"); var chunnelTwo = traderTwo.State.GetCurrent("EUR/GBP"); Assert.Greater(eurodolOne.AppliedEvents.Length, 0); Assert.Greater(eurodolTwo.AppliedEvents.Length, 0); Assert.Greater(chunnelOne.AppliedEvents.Length, 0); Assert.Greater(chunnelTwo.AppliedEvents.Length, 0); }