Exemple #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConsumerClient"/> class.
 /// </summary>
 /// <param name="clientManager">The <see cref="IClientManager" />.</param>
 /// <param name="subscriptions">The <see cref="ISubscriptions" />.</param>
 /// <param name="microservicesConfiguration">The <see cref="MicroservicesConfiguration" />.</param>
 /// <param name="streamProcessorStates">The <see cref="IStreamProcessorStateRepository" />.</param>
 /// <param name="eventHorizonEventsWriter">The <see cref="IWriteEventHorizonEvents" />.</param>
 /// <param name="policy">The <see cref="IAsyncPolicyFor{T}" /> <see cref="ConsumerClient" />.</param>
 /// <param name="eventProcessorPolicy">The <see cref="IAsyncPolicyFor{T}" /> <see cref="EventProcessor" />.</param>
 /// <param name="executionContextManager"><see cref="IExecutionContextManager" />.</param>
 /// <param name="reverseCallClients"><see cref="IReverseCallClients"/>.</param>
 /// <param name="logger">The <see cref="ILogger" />.</param>
 public ConsumerClient(
     IClientManager clientManager,
     ISubscriptions subscriptions,
     MicroservicesConfiguration microservicesConfiguration,
     IStreamProcessorStateRepository streamProcessorStates,
     IWriteEventHorizonEvents eventHorizonEventsWriter,
     IAsyncPolicyFor <ConsumerClient> policy,
     IAsyncPolicyFor <EventProcessor> eventProcessorPolicy,
     IExecutionContextManager executionContextManager,
     IReverseCallClients reverseCallClients,
     ILogger logger)
 {
     _clientManager = clientManager;
     _subscriptions = subscriptions;
     _microservicesConfiguration = microservicesConfiguration;
     _streamProcessorStates      = streamProcessorStates;
     _eventHorizonEventsWriter   = eventHorizonEventsWriter;
     _policy = policy;
     _eventProcessorPolicy    = eventProcessorPolicy;
     _executionContextManager = executionContextManager;
     _logger = logger;
     _cancellationTokenSource = new CancellationTokenSource();
     _cancellationToken       = _cancellationTokenSource.Token;
     _reverseCallClients      = reverseCallClients;
 }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Subscriptions"/> class.
 /// </summary>
 /// <param name="streamProcessorStates">The <see cref="IResilientStreamProcessorStateRepository" />.</param>
 /// <param name="eventsFetcherPolicy">The <see cref="IAsyncPolicyFor{T}" /> <see cref="ICanFetchEventsFromStream" />.</param>
 /// <param name="loggerManager">The <see cref="ILoggerManager" />.</param>
 public Subscriptions(IResilientStreamProcessorStateRepository streamProcessorStates, IAsyncPolicyFor <ICanFetchEventsFromStream> eventsFetcherPolicy, ILoggerManager loggerManager)
 {
     _streamProcessorStates = streamProcessorStates;
     _eventsFetcherPolicy   = eventsFetcherPolicy;
     _loggerManager         = loggerManager;
     _logger = loggerManager.CreateLogger <Subscriptions>();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FilterRegistry"/> class.
 /// </summary>
 /// <param name="processors">The <see cref="FilterProcessors"/> to use for creating filter processors.</param>
 /// <param name="policy">The <see cref="IAsyncPolicyFor{T}"/> that defines reconnect policies for the event filters.</param>
 public FilterRegistry(
     FilterProcessors processors,
     IAsyncPolicyFor <FilterRegistry> policy)
 {
     _processors = processors;
     _policy     = policy;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EventHandlerRegistry"/> class.
 /// </summary>
 /// <param name="processors">The <see cref="IEventHandlerProcessors"/> that will be used to create instances of <see cref="EventHandlerProcessor{TEventType}"/>.</param>
 /// <param name="policy">The <see cref="IAsyncPolicyFor{T}"/> that defines reconnect policies for event handlers.</param>
 /// <param name="completion">The <see cref="IEventProcessingCompletion"/> that handles waiting for event handlers.</param>
 public EventHandlerRegistry(
     IEventHandlerProcessors processors,
     IAsyncPolicyFor <EventHandlerRegistry> policy,
     IEventProcessingCompletion completion)
 {
     _processors = processors;
     _policy     = policy;
     _completion = completion;
 }
Exemple #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SubscriptionBootProcedure"/> class.
 /// </summary>
 /// <param name="configuration">The <see cref="EventHorizonsConfiguration"/> that contains all <see cref="Subscription"/>.</param>
 /// <param name="subscriptions">The <see cref="ISubscriptions"/> to use to subscribe.</param>
 /// <param name="policy">The <see cref="IAsyncPolicyFor{T}"/> that defines reconnect policies for the event horizon subscriptions.</param>
 /// <param name="logger">The <see cref="ILogger"/> used for logging.</param>
 public SubscriptionBootProcedure(
     EventHorizonsConfiguration configuration,
     ISubscriptions subscriptions,
     IAsyncPolicyFor <SubscriptionBootProcedure> policy,
     ILogger logger)
 {
     _configuration = configuration;
     _subscriptions = subscriptions;
     _policy        = policy;
     _logger        = logger;
 }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FailingPartitions"/> class.
 /// </summary>
 /// <param name="streamProcessorStates">The <see cref="IResilientStreamProcessorStateRepository" />.</param>
 /// <param name="eventProcessor">The <see cref="IEventProcessor" />.</param>
 /// <param name="eventsFromStreamsFetcher">The <see cref="ICanFetchEventsFromPartitionedStream" />.</param>
 /// <param name="eventsFetcherPolicy">The <see cref="IAsyncPolicyFor{T}" /> <see cref="ICanFetchEventsFromStream" />.</param>
 /// <param name="logger">The <see cref="ILogger" />.</param>
 public FailingPartitions(
     IResilientStreamProcessorStateRepository streamProcessorStates,
     IEventProcessor eventProcessor,
     ICanFetchEventsFromPartitionedStream eventsFromStreamsFetcher,
     IAsyncPolicyFor <ICanFetchEventsFromStream> eventsFetcherPolicy,
     ILogger <FailingPartitions> logger)
 {
     _streamProcessorStates    = streamProcessorStates;
     _eventProcessor           = eventProcessor;
     _eventsFromStreamsFetcher = eventsFromStreamsFetcher;
     _eventsFetcherPolicy      = eventsFetcherPolicy;
     _logger = logger;
 }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CreateScopedStreamProcessors"/> class.
 /// </summary>
 /// <param name="eventFetchers">The <see cref="IEventFetchers" />.</param>
 /// <param name="streamProcessorStates">The <see cref="IResilientStreamProcessorStateRepository" />.</param>
 /// <param name="executionContextManager">The <see cref="IExecutionContextManager" />.</param>
 /// <param name="eventsFetcherPolicy">The <see cref="IAsyncPolicyFor{T}" /> <see cref="ICanFetchEventsFromStream" />.</param>
 /// <param name="loggerManager">The <see cref="ILoggerManager" />.</param>
 public CreateScopedStreamProcessors(
     IEventFetchers eventFetchers,
     IResilientStreamProcessorStateRepository streamProcessorStates,
     IExecutionContextManager executionContextManager,
     IAsyncPolicyFor <ICanFetchEventsFromStream> eventsFetcherPolicy,
     ILoggerManager loggerManager)
 {
     _eventFetchers         = eventFetchers;
     _streamProcessorStates = streamProcessorStates;
     _eventsFetcherPolicy   = eventsFetcherPolicy;
     _loggerManager         = loggerManager;
     _tenant = executionContextManager.Current.Tenant;
 }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScopedStreamProcessor"/> class.
 /// </summary>
 /// <param name="tenantId">The <see cref="TenantId"/>.</param>
 /// <param name="streamProcessorId">The <see cref="IStreamProcessorId" />.</param>
 /// <param name="initialState">The <see cref="StreamProcessorState" />.</param>
 /// <param name="processor">An <see cref="IEventProcessor" /> to process the event.</param>
 /// <param name="streamProcessorStates">The <see cref="IResilientStreamProcessorStateRepository" />.</param>
 /// <param name="eventsFromStreamsFetcher">The<see cref="ICanFetchEventsFromStream" />.</param>
 /// <param name="eventsFetcherPolicy">The <see cref="IAsyncPolicyFor{T}" /> <see cref="ICanFetchEventsFromStream" />.</param>
 /// <param name="logger">An <see cref="ILogger" /> to log messages.</param>
 public ScopedStreamProcessor(
     TenantId tenantId,
     IStreamProcessorId streamProcessorId,
     StreamProcessorState initialState,
     IEventProcessor processor,
     IResilientStreamProcessorStateRepository streamProcessorStates,
     ICanFetchEventsFromStream eventsFromStreamsFetcher,
     IAsyncPolicyFor <ICanFetchEventsFromStream> eventsFetcherPolicy,
     ILogger <ScopedStreamProcessor> logger)
     : base(tenantId, streamProcessorId, initialState, processor, eventsFromStreamsFetcher, eventsFetcherPolicy, logger)
 {
     _streamProcessorStates = streamProcessorStates;
 }
Exemple #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EventProcessor"/> class.
 /// </summary>
 /// <param name="consentId">THe <see cref="ConsentId" />.</param>
 /// <param name="subscription">The <see cref="Subscription" />.</param>
 /// <param name="receivedEventsWriter">The <see cref="IWriteEventHorizonEvents" />.</param>
 /// <param name="policy">The <see cref="IAsyncPolicyFor{T}" /> <see cref="EventProcessor" />.</param>
 /// <param name="logger">The <see cref="ILogger" />.</param>
 public EventProcessor(
     ConsentId consentId,
     SubscriptionId subscription,
     IWriteEventHorizonEvents receivedEventsWriter,
     IAsyncPolicyFor <EventProcessor> policy,
     ILogger logger)
 {
     _consentId            = consentId;
     Scope                 = subscription.ScopeId;
     Identifier            = subscription.ProducerTenantId.Value;
     _subscriptionId       = subscription;
     _receivedEventsWriter = receivedEventsWriter;
     _policy               = policy;
     _logger               = logger;
 }
Exemple #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AbstractScopedStreamProcessor"/> class.
 /// </summary>
 /// <param name="tenantId">The <see cref="TenantId"/>.</param>
 /// <param name="streamProcessorId">The <see cref="IStreamProcessorId" />.</param>
 /// <param name="initialState">The initial state of the <see cref="IStreamProcessorState" />.</param>
 /// <param name="processor">An <see cref="IEventProcessor" /> to process the event.</param>
 /// <param name="eventsFetcher">The <see cref="ICanFetchEventsFromStream" />.</param>
 /// <param name="fetchEventsToProcessPolicy">The <see cref="IAsyncPolicyFor{T}" /> <see cref="ICanFetchEventsFromStream" />.</param>
 /// <param name="logger">An <see cref="ILogger" /> to log messages.</param>
 protected AbstractScopedStreamProcessor(
     TenantId tenantId,
     IStreamProcessorId streamProcessorId,
     IStreamProcessorState initialState,
     IEventProcessor processor,
     ICanFetchEventsFromStream eventsFetcher,
     IAsyncPolicyFor <ICanFetchEventsFromStream> fetchEventsToProcessPolicy,
     ILogger logger)
 {
     Identifier                 = streamProcessorId;
     Logger                     = logger;
     _currentState              = initialState;
     _tenantId                  = tenantId;
     _processor                 = processor;
     _eventsFetcher             = eventsFetcher;
     _fetchEventToProcessPolicy = fetchEventsToProcessPolicy;
 }
Exemple #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Subscription"/> class.
        /// </summary>
        /// <param name="consentId">The <see cref="ConsentId" />.</param>
        /// <param name="subscriptionId">The <see cref="StreamProcessorId" />.</param>
        /// <param name="eventProcessor">The <see cref="IEventProcessor" />.</param>
        /// <param name="eventsFetcher">The <see cref="EventsFromEventHorizonFetcher" />.</param>
        /// <param name="streamProcessorStates">The <see cref="IResilientStreamProcessorStateRepository" />.</param>
        /// <param name="unregister">An <see cref="Action" /> that unregisters the <see cref="ScopedStreamProcessor" />.</param>
        /// <param name="eventsFetcherPolicy">The <see cref="IAsyncPolicyFor{T}" /> <see cref="ICanFetchEventsFromStream" />.</param>
        /// <param name="loggerManager">The <see cref="ILoggerManager" />.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken" />.</param>
        public Subscription(
            ConsentId consentId,
            SubscriptionId subscriptionId,
            EventProcessor eventProcessor,
            EventsFromEventHorizonFetcher eventsFetcher,
            IResilientStreamProcessorStateRepository streamProcessorStates,
            Action unregister,
            IAsyncPolicyFor <ICanFetchEventsFromStream> eventsFetcherPolicy,
            ILoggerManager loggerManager,
            CancellationToken cancellationToken)
        {
            _identifier            = subscriptionId;
            _eventProcessor        = eventProcessor;
            _unregister            = unregister;
            _streamProcessorStates = streamProcessorStates;
            _eventsFetcher         = eventsFetcher;
            _eventsFetcherPolicy   = eventsFetcherPolicy;
            _loggerManager         = loggerManager;
            _logger                      = loggerManager.CreateLogger <StreamProcessor>();
            _cancellationToken           = cancellationToken;
            _unregisterTokenRegistration = _cancellationToken.Register(_unregister);

            ConsentId = consentId;
        }
Exemple #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ResilientStreamProcessorStateRepository"/> class.
 /// </summary>
 /// <param name="repository">The <see cref="IStreamProcessorStateRepository" />.</param>
 /// <param name="policy">The <see cref="IPolicyFor{T}" /> <see cref="ResilientStreamProcessorStateRepository" />.</param>
 public ResilientStreamProcessorStateRepository(IStreamProcessorStateRepository repository, IAsyncPolicyFor <ResilientStreamProcessorStateRepository> policy)
 {
     _repository = repository;
     _policy     = policy;
 }