public async Task ShouldBuildAStatelessActorAndRegisterABus() { var testBusRegistrationActor = StatelessActorBuilder <TestBuilderActor, TestActorBuilderDummyBusRegistry> .Create(ActorConfiguration.Default, _loggerFactory) .WithBus <ITestActorBuilderDummyBus>((actor, bus) => { actor.SubscribeTestActorDummyBus("somesubject"); }) .Build(); var dummyBus = testBusRegistrationActor.GetConnectedBus <ITestActorBuilderDummyBus>(); dummyBus.Push(new SomeData("entity", Guid.NewGuid())); await Task.Delay(200); Assert.AreEqual(1, testBusRegistrationActor.Events.Count); testBusRegistrationActor.Dispose(); }
static void Main(string[] args) { //var dispatchQueue = new DispatchQueue<int>(new DispatchQueueConfiguration<int>((i=> //{ // throw new Exception("boom"); //}),1,1)); //dispatchQueue.Enqueue(1); Task.Run(() => { var connectionSettings = StaticData.GetConnectionSettings(); var tradeDataEventProvider = new DefaultEventTypeProvider <Trade>(() => new[] { typeof(TradeCreated), typeof(TradeStatusChanged) }); var marketDataEventProvider = new DefaultEventTypeProvider <MarketData>(() => new[] { typeof(MarketDataChanged) }); var tradeService = EventStoreEmbeddedStatelessActorBuilder <TradeService, DemoSystemRegistry> .Create(StaticData.ClusterVNode, connectionSettings, ActorConfiguration.Default) .WithBus <IEventStoreBus>((actor, bus) => { actor.SubscribeFromEndToAllStreams(); }) .Build(); var tradePriceUpdateService = EventStoreEmbeddedStatefulActorBuilder <TradePriceUpdateService, Trade, DemoSystemRegistry> .Create(StaticData.ClusterVNode, connectionSettings, ActorConfiguration.Default) .WithReadAllFromStartCache(eventTypeProvider: tradeDataEventProvider) .WithBus <IEventStoreBus>((actor, bus) => { actor.SubscribeFromEndToAllStreams(); }) .WithBus <IMarketDataBus>((actor, bus) => { actor.SubscribeMarketDataBus(); }) .Build(); var tradeSink = EventStoreEmbeddedStatefulActorBuilder <TradeSink, Trade, DemoSystemRegistry> .Create(StaticData.ClusterVNode, connectionSettings, ActorConfiguration.Default) .WithReadAllFromStartCache(eventTypeProvider: tradeDataEventProvider) .Build(); var marketDataSink = StatelessActorBuilder <MarketDataSink, DemoSystemRegistry> .Create(ActorConfiguration.Default) .WithBus <IMarketDataBus>((actor, bus) => { actor.SubscribeMarketDataBus(); }) .Build(); var marketDataCache = marketDataSink.CurrentPrices.Connect(); var tradeCache = tradeSink.State.AsObservableCache().Connect(); tradeCache.PrintTradeChanges(); marketDataCache.PrintMarketDataChanges(); }); Console.Read(); }