public ProjectionWorkerNode( Guid workerId, TFChunkDb db, IQueuedHandler inputQueue, ITimeProvider timeProvider, ISingletonTimeoutScheduler timeoutScheduler, ProjectionType runProjections, bool faultOutOfOrderProjections) { _runProjections = runProjections; Ensure.NotNull(db, "db"); _coreOutput = new InMemoryBus("Core Output"); IPublisher publisher = CoreOutput; _subscriptionDispatcher = new ReaderSubscriptionDispatcher(publisher); _spoolProcessingResponseDispatcher = new SpooledStreamReadingDispatcher(publisher); _ioDispatcher = new IODispatcher(publisher, new PublishEnvelope(inputQueue)); _eventReaderCoreService = new EventReaderCoreService( publisher, _ioDispatcher, 10, db.Config.WriterCheckpoint, runHeadingReader: runProjections >= ProjectionType.System, faultOutOfOrderProjections: faultOutOfOrderProjections); _feedReaderService = new FeedReaderService(_subscriptionDispatcher, timeProvider); if (runProjections >= ProjectionType.System) { _projectionCoreServiceCommandReader = new ProjectionCoreServiceCommandReader( publisher, _ioDispatcher, workerId.ToString("N")); var multiStreamWriter = new MultiStreamMessageWriter(_ioDispatcher); _slaveProjectionResponseWriter = new SlaveProjectionResponseWriter(multiStreamWriter); _projectionCoreService = new ProjectionCoreService( workerId, inputQueue, publisher, _subscriptionDispatcher, timeProvider, _ioDispatcher, _spoolProcessingResponseDispatcher, timeoutScheduler); var responseWriter = new ResponseWriter(_ioDispatcher); _coreResponseWriter = new ProjectionCoreResponseWriter(responseWriter); } }
public static void CreateManagerService( StandardComponents standardComponents, ProjectionsStandardComponents projectionsStandardComponents, IDictionary <Guid, IPublisher> queues, TimeSpan projectionQueryExpiry) { IQueuedHandler inputQueue = projectionsStandardComponents.MasterInputQueue; InMemoryBus outputBus = projectionsStandardComponents.MasterOutputBus; var ioDispatcher = new IODispatcher(outputBus, new PublishEnvelope(inputQueue)); var projectionsController = new ProjectionsController( standardComponents.HttpForwarder, inputQueue, standardComponents.NetworkSendService); var forwarder = new RequestResponseQueueForwarder( inputQueue: projectionsStandardComponents.MasterInputQueue, externalRequestQueue: standardComponents.MainQueue); if (projectionsStandardComponents.RunProjections != ProjectionType.None) { foreach (var httpService in standardComponents.HttpServices) { httpService.SetupController(projectionsController); } } var commandWriter = new MultiStreamMessageWriter(ioDispatcher); var projectionManagerCommandWriter = new ProjectionManagerCommandWriter(commandWriter); var projectionManagerResponseReader = new ProjectionManagerResponseReader(outputBus, ioDispatcher, queues.Count); var projectionManager = new ProjectionManager( inputQueue, outputBus, queues, new RealTimeProvider(), projectionsStandardComponents.RunProjections, ioDispatcher, projectionQueryExpiry); SubscribeMainBus( projectionsStandardComponents.MasterMainBus, projectionManager, projectionsStandardComponents.RunProjections, projectionManagerResponseReader, ioDispatcher, projectionManagerCommandWriter); SubscribeOutputBus(standardComponents, projectionsStandardComponents, forwarder); }