/// <summary> /// Instantiates a new instance of <see cref="BootProcedure" /> /// </summary> /// <param name="systemsThatKnowAboutEventProcessors">Provides <see cref="IEventProcessor">Event Processors</see></param> /// <param name="tenants">A collection of all <see cref="ITenants">tenants</see></param> /// <param name="processingHub">An instance of <see cref="IScopedEventProcessingHub" /> for processing <see cref="CommittedEventStream">Committed Event Streams</see></param> /// <param name="getOffsetRepository">A factory function to return a correctly scoped instance of <see cref="IEventProcessorOffsetRepository" /></param> /// <param name="getUnprocessedEventsFetcher">A factory function to return a correctly scoped instance of <see cref="IFetchUnprocessedEvents" /></param> /// <param name="executionContextManager">The <see cref="ExecutionContextManager" /> for setting the correct execution context for the Event Processors </param> /// <param name="resourceConfiguration"></param> /// <param name="boundedContextLoader"></param> /// <param name="environment"></param> /// <param name="logger">An instance of <see cref="ILogger" /> for logging</param> public BootProcedure( IInstancesOf <IKnowAboutEventProcessors> systemsThatKnowAboutEventProcessors, ITenants tenants, IScopedEventProcessingHub processingHub, FactoryFor <IEventProcessorOffsetRepository> getOffsetRepository, FactoryFor <IFetchUnprocessedEvents> getUnprocessedEventsFetcher, IExecutionContextManager executionContextManager, IResourceConfiguration resourceConfiguration, IBoundedContextLoader boundedContextLoader, Execution.Environment environment, ILogger logger) { _processingHub = processingHub; _logger = logger; _tenants = tenants; _systemsThatKnowAboutEventProcessors = systemsThatKnowAboutEventProcessors; _getOffsetRepository = getOffsetRepository; _getUnprocessedEventsFetcher = getUnprocessedEventsFetcher; _executionContextManager = executionContextManager; _resourceConfiguration = resourceConfiguration; _logger = logger; var boundedContextConfig = boundedContextLoader.Load(); _executionContextManager.SetConstants(boundedContextConfig.Application, boundedContextConfig.BoundedContext, environment); }
/// <summary> /// Initializes a new instance of the <see cref="EventInjector"/> class. /// </summary> /// <param name="getEventStore"><see cref="FactoryFor{IEventStore}" /> factory function that returns a correctly scoped <see cref="IEventStore" />.</param> /// <param name="processingHub"><see cref="IScopedEventProcessingHub" /> for processing events from the <see cref="CommittedEventStream" />.</param> /// <param name="executionContextManager"><see cref="IExecutionContextManager"/> for working with <see cref="ExecutionContext"/>.</param> /// <param name="artifactTypeMap"><see cref="IArtifactTypeMap"/> for mapping artifacts and types.</param> /// <param name="logger"><see cref="ILogger" /> for logging.</param> public EventInjector( FactoryFor <IEventStore> getEventStore, IScopedEventProcessingHub processingHub, IExecutionContextManager executionContextManager, IArtifactTypeMap artifactTypeMap, ILogger logger) { _getEventStore = getEventStore; _processingHub = processingHub; _executionContextManager = executionContextManager; _artifactTypeMap = artifactTypeMap; _logger = logger; }
/// <summary> /// Instantiates an instance of ParticleStreamConsumer /// </summary> /// <param name="getEventStore"><see cref="FactoryFor{IEventStore}" /> factory function that returns a correctly scoped <see cref="IEventStore" /></param> /// <param name="getGeodesics"><see cref="FactoryFor{IGeodesics}" /> factory function that returns a correctly scoped <see cref="IGeodesics" /></param> /// <param name="key">The <see cref="EventHorizonKey" /> to identify the Event Horizon</param> /// <param name="processingHub"><see cref="IScopedEventProcessingHub" /> for processing events from the <see cref="CommittedEventStream" /></param> /// <param name="executionContextManager"></param> /// <param name="logger"><see cref="ILogger" /> for logging</param> public ParticleStreamProcessor( FactoryFor <IEventStore> getEventStore, FactoryFor <IGeodesics> getGeodesics, EventHorizonKey key, IScopedEventProcessingHub processingHub, IExecutionContextManager executionContextManager, ILogger logger) { _getEventStore = getEventStore; _getGeodesics = getGeodesics; _processingHub = processingHub; _eventHorizonKey = key; _executionContextManager = executionContextManager; _logger = logger; }
/// <summary> /// Initializes an instance of a <see cref="UncommittedEventStreamCoordinator"/> /// </summary> /// <param name="getEventStore">A <see cref="FactoryFor{IEventStore}" /> to return a correctly scoped instance of <see cref="IEventStore" /></param> /// <param name="eventProcessorHub"><see cref="IScopedEventProcessingHub"/> for processing in same bounded context</param> /// <param name="eventHorizon"><see cref="IEventHorizon"/> to pass events through to</param> /// <param name="artifactMap">An instance of <see cref="IArtifactTypeMap" /> to get the artifact for Event Source and Events</param> /// <param name="logger"><see cref="ILogger"/> for doing logging</param> /// <param name="systemClock"><see cref="ISystemClock"/> for getting the time</param> /// <param name="executionContextManager"><see cref="IExecutionContextManager"/> for accessing the current <see cref="ExecutionContext" /></param> public UncommittedEventStreamCoordinator( FactoryFor <IEventStore> getEventStore, IScopedEventProcessingHub eventProcessorHub, IEventHorizon eventHorizon, IArtifactTypeMap artifactMap, ILogger logger, ISystemClock systemClock, IExecutionContextManager executionContextManager) { _getEventStore = getEventStore; _eventProcessorHub = eventProcessorHub; _eventHorizon = eventHorizon; _logger = logger; _artifactMap = artifactMap; _systemClock = systemClock; _executionContextManager = executionContextManager; }
/// <summary> /// Initializes a new instance of the <see cref="Barrier"/> class. /// </summary> /// <param name="getGeodesics">A <see cref="FactoryFor{IGeodesics}"/> to get the correctly scoped geodesics for path offsetting.</param> /// <param name="serializer"><see cref="ISerializer"/> used for serialization.</param> /// <param name="getEventStore">A <see cref="FactoryFor{IEventStore}"/> to get the correctly scoped EventStore to persist incoming events to.</param> /// <param name="eventProcessingHub"><see cref="IScopedEventProcessingHub"/> for processing incoming events.</param> /// <param name="logger"><see cref="ILogger"/> for logging purposes.</param> /// <param name="executionContextManager"><see cref="IExecutionContextManager"/> to set the correct context for processing events.</param> /// <param name="tenants"><see cref="ITenants"/> all the tenants that we will process events for.</param> /// <param name="tenantOffsetRepository"><see cref="ITenantOffsetRepository"/> for working with the offsets per tenant.</param> /// <param name="application"><see cref="Application"/> running.</param> /// <param name="boundedContext"><see cref="BoundedContext"/> running.</param> public Barrier( FactoryFor <IGeodesics> getGeodesics, ISerializer serializer, FactoryFor <IEventStore> getEventStore, IScopedEventProcessingHub eventProcessingHub, ILogger logger, IExecutionContextManager executionContextManager, ITenants tenants, ITenantOffsetRepository tenantOffsetRepository, Application application, BoundedContext boundedContext) { _logger = logger; _getGeodesics = getGeodesics; _serializer = serializer; _getEventStore = getEventStore; _eventProcessingHub = eventProcessingHub; _executionContextManager = executionContextManager; _tenants = tenants; _tenantOffsetRepository = tenantOffsetRepository; _key = new EventHorizonKey(application, boundedContext); }
/// <summary> /// Initializes a new instance of the <see cref="QuantumTunnelConnection"/> class. /// </summary> /// <param name="horizonKey">The key for the connection.</param> /// <param name="destinationKey">The key for the destination.</param> /// <param name="address">Url for the <see cref="IEventHorizon"/> we're connecting to.</param> /// <param name="events"><see cref="IEnumerable{Artifact}">Events</see> to connect for.</param> /// <param name="getGeodesics">A <see cref="FactoryFor{IGeodesics}"/> to provide the correctly scoped geodesics instance for path offsetting.</param> /// <param name="getEventStore">A factory to provide the correctly scoped <see cref="IEventStore"/> to persist incoming events to.</param> /// <param name="eventProcessingHub"><see cref="IScopedEventProcessingHub"/> for processing incoming events.</param> /// <param name="serializer"><see cref="ISerializer"/> to use for deserializing content of commits.</param> /// <param name="logger"><see cref="ILogger"/> for logging purposes.</param> /// <param name="executionContextManager"><see cref="IExecutionContextManager"/> so we can set the correct context for the processing of the Events.</param> /// <param name="tenants"><see cref="ITenants"/> the tenants that we need to be aware of from the other bounded contexts.</param> /// <param name="tenantOffsetRepository"><see creF="ITenantOffsetRepository"/> to use for tracking offsets per tenant.</param> public QuantumTunnelConnection( EventHorizonKey horizonKey, EventHorizonKey destinationKey, string address, IEnumerable <Dolittle.Artifacts.Artifact> events, FactoryFor <IGeodesics> getGeodesics, FactoryFor <IEventStore> getEventStore, IScopedEventProcessingHub eventProcessingHub, ISerializer serializer, ILogger logger, IExecutionContextManager executionContextManager, ITenants tenants, ITenantOffsetRepository tenantOffsetRepository) { _address = address; _events = events; _logger = logger; _horizonKey = horizonKey; _destinationKey = destinationKey; _getGeodesics = getGeodesics; _serializer = serializer; _getEventStore = getEventStore; _eventProcessingHub = eventProcessingHub; _channel = new Channel(_address, ChannelCredentials.Insecure); _client = new QuantumTunnelService.QuantumTunnelServiceClient(_channel); _runCancellationTokenSource = new CancellationTokenSource(); _runCancellationToken = _runCancellationTokenSource.Token; _executionContextManager = executionContextManager; _processor = new ParticleStreamProcessor(getEventStore, getGeodesics, _destinationKey, eventProcessingHub, _executionContextManager, logger); _tenantOffsetRepository = tenantOffsetRepository; _tenants = tenants; AppDomain.CurrentDomain.ProcessExit += ProcessExit; AssemblyLoadContext.Default.Unloading += AssemblyLoadContextUnloading; Task.Run(() => Run(), _runCancellationToken); Console.CancelKeyPress += (s, e) => Close(); }