Exemplo n.º 1
0
        /// <summary>
        /// Builds an <see cref="IEventHandler{TEventType}"/> from <typeparamref name="THandlerType"/> using a <see cref="FactoryFor{T}"/> to invoke the handler methods.
        /// </summary>
        /// <typeparam name="THandlerType">The type of the event handler to build for.</typeparam>
        /// <param name="factory">The <see cref="FactoryFor{T}"/> that will be used to instantiate the event handler.</param>
        /// <returns>A <see cref="IEventHandler{TEventType}"/> that can be registered with an <see cref="IRegisterEventHandlers"/>.</returns>
        public static IEventHandler <TEventType> BuildFor <THandlerType>(FactoryFor <THandlerType> factory)
        {
            var builder     = EventHandlerBuilder.Create <TEventType>().With(factory);
            var handlerType = typeof(THandlerType);

            foreach (var method in handlerType.GetMethods(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public))
            {
                ThrowIfMethodHasCorrectSignatureButWrongName(method);

                if (method.Name == HandleMethodName)
                {
                    ThrowIfFirstMethodParameterIsNot <TEventType>(method);
                    ThrowIfSecondMethodParameterIsNotEventContext(method);
                    ThrowIfMethodHasExtraParameters(method);
                    ThrowIfMethodDoesNotReturnATask(method);

                    TryGetFirstMethodParameter <TEventType>(method, out var eventType);
                    var delegateType        = typeof(EventHandlerMethod <,>).MakeGenericType(handlerType, eventType);
                    var dynamicDelegate     = method.CreateDelegate(delegateType, null);
                    var builderHandleMethod = typeof(EventHandlerFactoryBuilder <THandlerType, TEventType>).GetMethod(nameof(EventHandlerFactoryBuilder <THandlerType, TEventType> .Handle));
                    var dynamicHandleMethod = builderHandleMethod.MakeGenericMethod(eventType);
                    dynamicHandleMethod.Invoke(builder, new[] {  dynamicDelegate });
                }
            }

            return(builder.Build());
        }
Exemplo n.º 2
0
 public LocalAuthenticator(ICanResolveTenantsForProviderSubjects mapper, IExecutionContextManager manager, FactoryFor <ICanResolveUserForProviderSubjects> userMapperFactory, ICanGenerateTenantPrincipal generator)
 {
     _mapper            = mapper;
     _manager           = manager;
     _userMapperFactory = userMapperFactory;
     _generator         = generator;
 }
Exemplo n.º 3
0
 public Boot(IExecutionContextManager contextManager, ITenants tenants, FactoryFor <ConfigurationManager> configurationManagerFactory, ILogger logger)
 {
     _contextManager = contextManager;
     _tenants        = tenants;
     _configurationManagerFactory = configurationManagerFactory;
     _logger = logger;
 }
 /// <summary>
 /// Instantiates an instance of <see cref="BuildPodProcessor" />
 /// </summary>
 /// <param name="executionContextManager">The <see cref="IExecutionContextManager" /> for setting the correct <see cref="Tenant"/> context</param>
 /// <param name="handleBuildSteps">A <see cref="IHandleBuildSteps" /> for handling each build step</param>
 /// <param name="getTracker">A factory for building instances of <see cref="IBuildStepsStatusTracker" /> for tracking the status of individual build steps</param>
 /// <param name="logger">A logger for logging</param>
 public BuildPodProcessor(IExecutionContextManager executionContextManager, IHandleBuildSteps handleBuildSteps, FactoryFor <IBuildStepsStatusTracker> getTracker, ILogger logger)
 {
     _logger                  = logger;
     _handleBuildSteps        = handleBuildSteps;
     _getTracker              = getTracker;
     _executionContextManager = executionContextManager;
 }
Exemplo n.º 5
0
        /// <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);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EventStoreService"/> class.
 /// </summary>
 /// <param name="eventStoreFactory"><see cref="IEventStore"/>.</param>
 /// <param name="executionContextManager"><see cref="IExecutionContextManager" />.</param>
 /// <param name="logger"><see cref="ILogger"/> for logging.</param>
 public EventStoreService(
     FactoryFor <IEventStore> eventStoreFactory,
     IExecutionContextManager executionContextManager,
     ILogger <EventStoreService> logger)
 {
     _eventStoreFactory       = eventStoreFactory;
     _executionContextManager = executionContextManager;
     _logger = logger;
 }
 public WebhookCoordinator(
     ITenantMapper tenantMapper,
     FactoryFor <IWebhookScheduler> schedulerFactory,
     IExecutionContextManager executionContextManager
     )
 {
     _tenantMapper            = tenantMapper;
     _schedulerFactory        = schedulerFactory;
     _executionContextManager = executionContextManager;
 }
Exemplo n.º 8
0
 /// <summary>
 /// Instantiates an instance of <see cref="ScopedEventProcessor" />
 /// </summary>
 /// <param name="tenant">The <see cref="TenantId" /> that this processor is scoped to.</param>
 /// <param name="processor">An <see cref="IEventProcessor" /> to process the event</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="logger">An <see cref="ILogger" /> to log messages</param>
 public ScopedEventProcessor(TenantId tenant, IEventProcessor processor, FactoryFor <IEventProcessorOffsetRepository> getOffsetRepository,
                             FactoryFor <IFetchUnprocessedEvents> getUnprocessedEventsFetcher, ILogger logger)
 {
     LastVersionProcessed = CommittedEventVersion.None;
     _tenant    = tenant;
     _processor = processor;
     _logger    = logger;
     Key        = new ScopedEventProcessorKey(tenant, processor.Event);
     _getUnprocessedEventsFetcher = getUnprocessedEventsFetcher;
     _getOffsetRepository         = getOffsetRepository;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ValidateFilterForAllTenants"/> class.
 /// </summary>
 /// <param name="onAllTenants">The <see cref="IPerformActionOnAllTenants" />.</param>
 /// <param name="filterValidators">The <see cref="IFilterValidators" />.</param>
 /// <param name="getFilterDefinitions">The <see cref="FactoryFor{T}" /> <see cref="IFilterDefinitions" />.</param>
 /// <param name="logger">The <see cref="ILogger" />.</param>
 public ValidateFilterForAllTenants(
     IPerformActionOnAllTenants onAllTenants,
     IFilterValidators filterValidators,
     FactoryFor <IFilterDefinitions> getFilterDefinitions,
     ILogger logger)
 {
     _onAllTenants         = onAllTenants;
     _filterValidators     = filterValidators;
     _getFilterDefinitions = getFilterDefinitions;
     _logger = logger;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of <see cref="PullConnectors"/>
 /// </summary>
 /// <param name="configurationFactory"></param>
 /// <param name="connectors"></param>
 /// <param name="communicationClient"></param>
 /// <param name="logger"></param>
 public PullConnectors(
     FactoryFor <PullConnectorsConfiguration> configurationFactory,
     IInstancesOf <IAmAPullConnector> connectors,
     ICommunicationClient communicationClient,
     ILogger logger)
 {
     _connectors          = connectors;
     _communicationClient = communicationClient;
     _logger = logger;
     _configurationFactory = configurationFactory;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SubscriptionsService"/> class.
 /// </summary>
 /// <param name="getConsumerClient">The <see cref="FactoryFor{T}" /><see cref="IConsumerClient" />.</param>
 /// <param name="executionContextManager"><see cref="IExecutionContextManager"/> for current <see cref="Execution.ExecutionContext"/>.</param>
 /// <param name="tenants">The <see cref="ITenants"/> system.</param>
 /// <param name="logger"><see cref="ILogger"/> for logging.</param>
 public SubscriptionsService(
     FactoryFor <IConsumerClient> getConsumerClient,
     IExecutionContextManager executionContextManager,
     ITenants tenants,
     ILogger <SubscriptionsService> logger)
 {
     _getConsumerClient       = getConsumerClient;
     _executionContextManager = executionContextManager;
     _tenants = tenants;
     _logger  = logger;
 }
 /// <summary>
 /// Instantiates an instance of <see cref="ImprovementScheduler" />
 /// </summary>
 /// <param name="executionContextManager">An <see cref="IExecutionContextManager" /> for accessing the current <see cref="ExecutionContext" /></param>
 /// <param name="improvementPodFactory">An <see cref="IImprovementPodFactory" /> for creating <see cref="V1Pod">improvement pods</see></param>
 /// <param name="improvableManager">An <see cref="IImprovableManager" /> for fetching an <see cref="Improvable" /></param>
 /// <param name="kubernetesClientFactory">A factory for creating <see cref="IKubernetes">kubernetes client</see></param>
 public ImprovementScheduler(
     IExecutionContextManager executionContextManager,
     IImprovementPodFactory improvementPodFactory,
     IImprovableManager improvableManager,
     FactoryFor <IKubernetes> kubernetesClientFactory)
 {
     _executionContextManager = executionContextManager;
     _improvementPodFactory   = improvementPodFactory;
     _kubernetesClientFactory = kubernetesClientFactory;
     _improvableManager       = improvableManager;
 }
Exemplo n.º 13
0
 public CaseReportsController(
     IExecutionContextConfigurator executionContextConfigurator,
     ITenantResolver tenantResolver,
     IInstancesOf <ICanExportCaseReports> exporters,
     FactoryFor <AllCaseReportsForListing> allCaseReports
     )
 {
     _executionContextConfigurator = executionContextConfigurator;
     _tenantResolver = tenantResolver;
     _exporters      = exporters;
     _allCaseReports = allCaseReports;
 }
Exemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StreamProcessors"/> class.
 /// </summary>
 /// <param name="onAllTenants">The <see cref="IPerformActionOnAllTenants" />.</param>
 /// <param name="getScopedStreamProcessorsCreator">The <see cref="FactoryFor{T}" /> <see cref="ICreateScopedStreamProcessors" />.</param>
 /// <param name="executionContextManager">The <see cref="IExecutionContextManager" />.</param>
 /// <param name="loggerManager">The <see cref="ILoggerManager" />.</param>
 public StreamProcessors(
     IPerformActionOnAllTenants onAllTenants,
     FactoryFor <ICreateScopedStreamProcessors> getScopedStreamProcessorsCreator,
     IExecutionContextManager executionContextManager,
     ILoggerManager loggerManager)
 {
     _onAllTenants = onAllTenants;
     _getScopedStreamProcessorsCreator = getScopedStreamProcessorsCreator;
     _streamProcessors        = new ConcurrentDictionary <StreamProcessorId, StreamProcessor>();
     _executionContextManager = executionContextManager;
     _loggerManager           = loggerManager;
     _logger = loggerManager.CreateLogger <StreamProcessors>();
 }
 public IdentityServerOptionsProvider(
     IExecutionContextManager executionManager,
     IPortalContextManager portalManager,
     IInstancesOf <ICanConfigureIdentityServer> configurers,
     FactoryFor <ICanConfigureIdentityServerForPortal> portalConfigurerFactory
     )
 {
     _executionManager        = executionManager;
     _portalManager           = portalManager;
     _configurers             = configurers;
     _portalConfigurerFactory = portalConfigurerFactory;
     _defaultOptions          = DefaultOptions();
 }
 /// <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;
 }
Exemplo n.º 17
0
        public static Mock <ScopedEventProcessor> a_scoped_event_processor_mock(TenantId tenant, IEventProcessor eventProcessor, ILogger logger = null)
        {
            var offset_repository         = new Mock <IEventProcessorOffsetRepository>();
            var unprocessed_event_fetcher = new Mock <IFetchUnprocessedEvents>();

            FactoryFor <IEventProcessorOffsetRepository> offset_provider      = () => offset_repository.Object;
            FactoryFor <IFetchUnprocessedEvents>         unprocessed_provider = () => unprocessed_event_fetcher.Object;

            return(new Mock <ScopedEventProcessor>(tenant,
                                                   eventProcessor,
                                                   offset_provider,
                                                   unprocessed_provider,
                                                   logger ?? mocks.a_logger().Object));
        }
Exemplo n.º 18
0
 /// <summary>
 /// Instantiates an instance of <see cref="WebhookCoordinator" />
 /// </summary>
 /// <param name="tenantMapper">An installation to tenant mapper</param>
 /// <param name="schedulerFactory">A factory for creating an instance of the scheduler</param>
 /// <param name="executionContextManager">The execution context manager for scoping to the correct tenant</param>
 /// <param name="handlerRegistry">The handler registry for finding the correct handlers for the webhook type</param>
 /// <param name="logger">A logger for logging</param>
 public WebhookCoordinator(
     IInstallationToTenantMapper tenantMapper,
     FactoryFor <IWebhookScheduler> schedulerFactory,
     IExecutionContextManager executionContextManager,
     IWebhookHandlerRegistry handlerRegistry,
     ILogger logger
     )
 {
     _tenantMapper            = tenantMapper;
     _schedulerFactory        = schedulerFactory;
     _executionContextManager = executionContextManager;
     _logger          = logger;
     _handlerRegistry = handlerRegistry;
 }
Exemplo n.º 19
0
        // FIXME: This class needs some cleanup...

        public KubernetesBuildPodWatcher(
            ILogger logger,
            IExecutionContextManager executionContextManager,
            FactoryFor <IKubernetes> clientFactory,
            FactoryFor <IImprovementStepResultHandler> stepResultHandlerFactory,
            FactoryFor <IImprovementResultHandler> improvementResultHandlerFactory
            )
        {
            _clientFactory                   = clientFactory;
            _logger                          = logger;
            _executionContextManager         = executionContextManager;
            _stepResultHandlerFactory        = stepResultHandlerFactory;
            _improvementResultHandlerFactory = improvementResultHandlerFactory;
        }
Exemplo n.º 20
0
 /// <summary>
 /// Instantiates an instance of <see cref="BuildPodWatcher" />
 /// </summary>
 /// <param name="logger">A <see cref="ILogger">logger</see></param>
 /// <param name="executionContextManager">An <see cref="IExecutionContextManager"> execution context manager</see></param>
 /// <param name="clientFactory">A factory for creating an <see cref="IKubernetes"> kubernetes client</see></param>
 /// <param name="metadataFactory">A factory for creating <see cref="ImprovementMetadata" /> </param>
 /// <param name="buildPodProcessor">An <see cref="IBuildPodProcessor"> build pod processor</see></param>
 public BuildPodWatcher(
     ILogger logger,
     IExecutionContextManager executionContextManager,
     FactoryFor <IKubernetes> clientFactory,
     IImprovementMetadataFactory metadataFactory,
     IBuildPodProcessor buildPodProcessor
     )
 {
     _clientFactory           = clientFactory;
     _logger                  = logger;
     _executionContextManager = executionContextManager;
     _metadataFactory         = metadataFactory;
     _buildPodProcessor       = buildPodProcessor;
 }
Exemplo n.º 21
0
        /// <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;
        }
Exemplo n.º 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConsumerService"/> class.
 /// </summary>
 /// <param name="boundedContextConfiguration">The <see cref="BoundedContextConfiguration" />.</param>
 /// <param name="executionContextManager"><see cref="IExecutionContextManager"/> for current <see cref="Execution.ExecutionContext"/>.</param>
 /// <param name="eventHorizonConsents">The <see cref="EventHorizonConsentsConfiguration" />.</param>
 /// <param name="tenants">The <see cref="ITenants"/> system.</param>
 /// <param name="getEventFetchers">The <see cref="FactoryFor{T}" /> <see cref="IEventFetchers" />.</param>
 /// <param name="dispatchers">The <see cref="IReverseCallDispatchers" />.</param>
 /// <param name="logger"><see cref="ILogger"/> for logging.</param>
 public ConsumerService(
     BoundedContextConfiguration boundedContextConfiguration,
     IExecutionContextManager executionContextManager,
     EventHorizonConsentsConfiguration eventHorizonConsents,
     ITenants tenants,
     FactoryFor <IEventFetchers> getEventFetchers,
     IReverseCallDispatchers dispatchers,
     ILogger <ConsumerService> logger)
 {
     _thisMicroservice        = boundedContextConfiguration.BoundedContext;
     _executionContextManager = executionContextManager;
     _eventHorizonConsents    = eventHorizonConsents;
     _tenants          = tenants;
     _getEventFetchers = getEventFetchers;
     _dispatchers      = dispatchers;
     _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;
        }
Exemplo n.º 24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EventHandlersService"/> class.
 /// </summary>
 /// <param name="hostApplicationLifetime">The <see cref="IHostApplicationLifetime" />.</param>
 /// <param name="filterForAllTenants">The <see cref="IValidateFilterForAllTenants" />.</param>
 /// <param name="streamProcessors">The <see cref="IStreamProcessors" />.</param>
 /// <param name="getEventsToStreamsWriter">The <see cref="FactoryFor{T}" /> <see cref="IWriteEventsToStreams" />.</param>
 /// <param name="streamDefinitions">The<see cref="IStreamDefinitions" />.</param>
 /// <param name="reverseCallDispatchers">The <see cref="IReverseCallDispatchers"/> for working with reverse calls.</param>
 /// <param name="executionContextManager">The <see cref="IExecutionContextManager" />.</param>
 /// <param name="loggerManager">The <see cref="ILoggerManager"/>.</param>
 public EventHandlersService(
     IHostApplicationLifetime hostApplicationLifetime,
     IValidateFilterForAllTenants filterForAllTenants,
     IStreamProcessors streamProcessors,
     FactoryFor <IWriteEventsToStreams> getEventsToStreamsWriter,
     IStreamDefinitions streamDefinitions,
     IReverseCallDispatchers reverseCallDispatchers,
     IExecutionContextManager executionContextManager,
     ILoggerManager loggerManager)
 {
     _filterForAllTenants      = filterForAllTenants;
     _streamProcessors         = streamProcessors;
     _getEventsToStreamsWriter = getEventsToStreamsWriter;
     _streamDefinitions        = streamDefinitions;
     _reverseCallDispatchers   = reverseCallDispatchers;
     _executionContextManager  = executionContextManager;
     _loggerManager            = loggerManager;
     _logger = loggerManager.CreateLogger <EventHandlersService>();
     _hostApplicationLifetime = hostApplicationLifetime;
 }
Exemplo n.º 25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StreamProcessor"/> class.
 /// </summary>
 /// <param name="streamProcessorId">The <see cref="StreamProcessorId" />.</param>
 /// <param name="onAllTenants">The <see cref="IPerformActionOnAllTenants" />.</param>
 /// <param name="streamDefinition">The <see cref="IStreamDefinition" />.</param>
 /// <param name="getEventProcessor">The <see cref="Func{TResult}" /> that returns an <see cref="IEventProcessor" />.</param>
 /// <param name="unregister">An <see cref="Action" /> that unregisters the <see cref="ScopedStreamProcessor" />.</param>
 /// <param name="getScopedStreamProcessorsCreator">The <see cref="ICreateScopedStreamProcessors" />.</param>
 /// <param name="executionContextManager">The <see cref="IExecutionContextManager" />.</param>
 /// <param name="logger">The <see cref="ILogger" />.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken" />.</param>
 public StreamProcessor(
     StreamProcessorId streamProcessorId,
     IPerformActionOnAllTenants onAllTenants,
     IStreamDefinition streamDefinition,
     Func <IEventProcessor> getEventProcessor,
     Action unregister,
     FactoryFor <ICreateScopedStreamProcessors> getScopedStreamProcessorsCreator,
     IExecutionContextManager executionContextManager,
     ILogger <StreamProcessor> logger,
     CancellationToken cancellationToken)
 {
     _identifier        = streamProcessorId;
     _onAllTenants      = onAllTenants;
     _streamDefinition  = streamDefinition;
     _getEventProcessor = getEventProcessor;
     _unregister        = unregister;
     _getScopedStreamProcessorsCreator = getScopedStreamProcessorsCreator;
     _executionContextManager          = executionContextManager;
     _logger = logger;
     _internalCancellationTokenSource = new CancellationTokenSource();
     _externalCancellationToken       = cancellationToken;
     _unregisterTokenRegistration     = _externalCancellationToken.Register(_unregister);
 }
Exemplo n.º 26
0
        /// <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);
        }
Exemplo n.º 27
0
        /// <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();
        }
Exemplo n.º 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FetchUnprocessedCommits"/> class.
 /// </summary>
 /// <param name="getEventStore"><see cref="FactoryFor{T}"/> for <see cref="IEventStore"/>.</param>
 public FetchUnprocessedCommits(FactoryFor <IEventStore> getEventStore)
 {
     _getEventStore = getEventStore;
 }
Exemplo n.º 29
0
 /// <summary>
 /// Instantiates an instance of <see cref="TenantOffsetRepository" />
 /// </summary>
 /// <param name="getGeodesics">a <see cref="FactoryFor{IGeodesics}" /> for retrieving the correctly scoped geodesics</param>
 /// <param name="executionContextManager"><see cref="IExecutionContextManager" /> for ensuring the correct execution context</param>
 public TenantOffsetRepository(FactoryFor <IGeodesics> getGeodesics, IExecutionContextManager executionContextManager)
 {
     _getGeodesics            = getGeodesics;
     _executionContextManager = executionContextManager;
 }
Exemplo n.º 30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StreamDefinitions"/> class.
 /// </summary>
 /// <param name="onAllTenants">The <see cref="IPerformActionOnAllTenants" />.</param>
 /// <param name="getStreamDefinitions">The <see cref="FactoryFor{T}" /> <see cref="IStreamDefinitionRepository" />.</param>
 public StreamDefinitions(IPerformActionOnAllTenants onAllTenants, FactoryFor <IStreamDefinitionRepository> getStreamDefinitions)
 {
     _onAllTenants         = onAllTenants;
     _getStreamDefinitions = getStreamDefinitions;
 }