/// <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); }
/// <inheritdoc/> public ExecutionContext ConfigureFor(TenantId tenantId, CorrelationId correlationId, Claims claims) { var executionEnvironment = DeduceEnvironment(); var executionApplication = DeduceApplication(); var executionBoundedContext = DeduceBoundedContext(); _executionContextManager.SetConstants(executionApplication, executionBoundedContext, executionEnvironment); return(_executionContextManager.CurrentFor(tenantId, correlationId, claims)); }
/// <inheritdoc/> public ExecutionContext ConfigureFor(TenantId tenantId, CorrelationId correlationId, Claims claims) { var executionEnvironment = EnvironmentUtilities.GetExecutionEnvironment(); var executionApplication = DeduceApplication(); var executionBoundedContext = DeduceBoundedContext(); _executionContextManager.SetConstants(executionApplication, executionBoundedContext, executionEnvironment); return(_executionContextManager.CurrentFor(tenantId, correlationId, claims ?? Dolittle.Security.Claims.Empty)); }
/// <inheritdoc/> public void Perform() { var environment = _executionContextManager.Current.Environment; _resourceConfiguration.ConfigureResourceTypes( _boundedContextConfiguration.Resources.ToDictionary( kvp => kvp.Key, kvp => environment == Environment.Production ? kvp.Value.Production : kvp.Value.Development)); _executionContextManager.SetConstants(_boundedContextConfiguration.BoundedContext, Version.NotSet, environment); _executionContextManager.CurrentFor(_boundedContextConfiguration.BoundedContext, _executionContextManager.Current.Tenant); HasPerformed = true; }
/// <summary> /// Initializes a new instance of the <see cref="BootProcedure"/> class. /// </summary> /// <param name="eventHorizons"><see cref="EventHorizonsConfiguration">Event horizons configuration</see>.</param> /// <param name="barrier"><see cref="IBarrier">Barrier</see> to penetrate towards an <see cref="IEventHorizon"/>.</param> /// <param name="resourceConfiguration"><see cref="IResourceConfiguration"/> for resources.</param> /// <param name="executionContextManager"><see cref="IExecutionContextManager"/> for working with <see cref="ExecutionContext"/>.</param> /// <param name="application">The running <see cref="Application"/>.</param> /// <param name="boundedContext">The running <see cref="BoundedContext"/>.</param> /// <param name="environment">The running environment.</param> public BootProcedure( EventHorizonsConfiguration eventHorizons, IBarrier barrier, IResourceConfiguration resourceConfiguration, IExecutionContextManager executionContextManager, Application application, BoundedContext boundedContext, Environment environment) { _eventHorizons = eventHorizons; _barrier = barrier; _resourceConfiguration = resourceConfiguration; executionContextManager.SetConstants(application, boundedContext, environment); }
/// <summary> /// Initializes a new instance of <see cref="BootProcedure"/> /// </summary> /// <param name="configuration"><see cref="IEventHorizonsConfigurationManager">Configuration mananger</see></param> /// <param name="barrier"><see cref="IBarrier">Barrier</see> to penetrate towards an <see cref="IEventHorizon"/></param> /// <param name="resourceConfiguration"></param> /// <param name="boundedContextLoader"></param> /// <param name="executionContextManager"></param> /// <param name="environment">The running environment</param> public BootProcedure( IEventHorizonsConfigurationManager configuration, IBarrier barrier, IResourceConfiguration resourceConfiguration, IBoundedContextLoader boundedContextLoader, IExecutionContextManager executionContextManager, Environment environment) { _configuration = configuration; _barrier = barrier; _resourceConfiguration = resourceConfiguration; _boundedContextLoader = boundedContextLoader; var boundedContextConfig = boundedContextLoader.Load(); executionContextManager.SetConstants(boundedContextConfig.Application, boundedContextConfig.BoundedContext, environment); }