/// <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="CreateScopedFilterStreamProcessors"/> class. /// </summary> /// <param name="streamProcessorStates">The stream processor states repository to use to get or create the current state of the stream processor.</param> /// <param name="streamWatcher">The stream watcher to use to notify waiters when the stream processor is created..</param> /// <param name="eventLogStream">The <see cref="IEventLogStream"/>.</param> /// <param name="createFilterStreamProcessor">The factory to use to create instances of unpartitioned stream processors.</param> public CreateScopedFilterStreamProcessors( IResilientStreamProcessorStateRepository streamProcessorStates, IStreamEventWatcher streamWatcher, IEventLogStream eventLogStream, Func <ChannelReader <EventLogBatch>, StreamProcessorId, bool, StreamProcessorState, ScopedFilterStreamProcessor> createFilterStreamProcessor) { _streamProcessorStates = streamProcessorStates; _streamWatcher = streamWatcher; _eventLogStream = eventLogStream; _createFilterStreamProcessor = createFilterStreamProcessor; }
/// <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; }
/// <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; }
/// <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; }
/// <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="createExecutionContextForEvent">The factory to use to create execution contexts for event processing.</param> /// <param name="eventFetcherPolicies">The policies to use for fetching events.</param> public FailingPartitions( IResilientStreamProcessorStateRepository streamProcessorStates, IEventProcessor eventProcessor, ICanFetchEventsFromPartitionedStream eventsFromStreamsFetcher, Func <StreamEvent, ExecutionContext> createExecutionContextForEvent, //TODO: Oh man, here we go again. IEventFetcherPolicies eventFetcherPolicies) { _streamProcessorStates = streamProcessorStates; _eventProcessor = eventProcessor; _eventsFromStreamsFetcher = eventsFromStreamsFetcher; _createExecutionContextForEvent = createExecutionContextForEvent; _eventFetcherPolicies = eventFetcherPolicies; }
/// <summary> /// Initializes a new instance of the <see cref="CreateScopedStreamProcessors"/> class. /// </summary> /// <param name="eventFetchers">The factory to use to create the partitioned or unpartitioned stream event fetchers.</param> /// <param name="streamProcessorStates">The stream processor states repository to use to get or create the current state of the stream processor.</param> /// <param name="streamWatcher">The stream watcher to use to notify waiters when the stream processor is created..</param> /// <param name="createPartitionedStreamProcessor">The factory to use to create instances of partitioned stream processors.</param> /// <param name="createUnpartitionedStreamProcessor">The factory to use to create instances of unpartitioned stream processors.</param> public CreateScopedStreamProcessors( IEventFetchers eventFetchers, IResilientStreamProcessorStateRepository streamProcessorStates, IStreamEventWatcher streamWatcher, Func <IStreamDefinition, IStreamProcessorId, ICanFetchEventsFromPartitionedStream, IEventProcessor, Partitioned.StreamProcessorState, ExecutionContext, Partitioned.ScopedStreamProcessor> createPartitionedStreamProcessor, Func <IStreamDefinition, IStreamProcessorId, ICanFetchEventsFromStream, IEventProcessor, StreamProcessorState, ExecutionContext, ScopedStreamProcessor> createUnpartitionedStreamProcessor) { _eventFetchers = eventFetchers; _streamProcessorStates = streamProcessorStates; _streamWatcher = streamWatcher; _createPartitionedStreamProcessor = createPartitionedStreamProcessor; _createUnpartitionedStreamProcessor = createUnpartitionedStreamProcessor; }
/// <summary> /// Initializes an instance of the <see cref="StreamProcessor" /> class. /// </summary> /// <param name="streamProcessorStates">The <see cref="IResilientStreamProcessorStateRepository" />.</param> /// <param name="externalEventsCommitter">The <see cref="ICommitExternalEvents"/></param> /// <param name="eventsFetcherPolicy">The <see cref="IAsyncPolicyFor{T}"/> <see cref="ICanFetchEventsFromStream" />.</param> /// <param name="metrics">The system for collecting metrics.</param> /// <param name="loggerFactory">The <see cref="ILoggerFactory" />.</param> public StreamProcessorFactory( IResilientStreamProcessorStateRepository streamProcessorStates, ICommitExternalEvents externalEventsCommitter, IEventFetcherPolicies eventsFetcherPolicy, IMetricsCollector metrics, ILoggerFactory loggerFactory ) { _streamProcessorStates = streamProcessorStates; _externalEventsCommitter = externalEventsCommitter; _eventsFetcherPolicy = eventsFetcherPolicy; _metrics = metrics; _loggerFactory = loggerFactory; }
/// <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="sourceStreamDefinition">The source stream <see cref="IStreamDefinition" />.</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="executionContext">The <see cref="ExecutionContext"/> of the stream processor.</param> /// <param name="eventFetcherPolicies">The policies to use while fetching events.</param> /// <param name="eventWatcher">The <see cref="IStreamEventWatcher" /> to wait for events to be available in stream.</param> /// <param name="timeToRetryGetter">The <see cref="ICanGetTimeToRetryFor{T}" /> <see cref="StreamProcessorState" />.</param> /// <param name="logger">An <see cref="ILogger" /> to log messages.</param> public ScopedStreamProcessor( TenantId tenantId, IStreamProcessorId streamProcessorId, IStreamDefinition sourceStreamDefinition, StreamProcessorState initialState, IEventProcessor processor, IResilientStreamProcessorStateRepository streamProcessorStates, ICanFetchEventsFromStream eventsFromStreamsFetcher, ExecutionContext executionContext, IEventFetcherPolicies eventFetcherPolicies, IStreamEventWatcher eventWatcher, ICanGetTimeToRetryFor <StreamProcessorState> timeToRetryGetter, ILogger logger) : base(tenantId, streamProcessorId, sourceStreamDefinition, initialState, processor, eventsFromStreamsFetcher, executionContext, eventFetcherPolicies, eventWatcher, logger) { _streamProcessorStates = streamProcessorStates; _timeToRetryGetter = timeToRetryGetter; }
/// <summary> /// Initializes a new instance of the <see cref="StreamProcessor"/> class. /// </summary> /// <param name="subscriptionId">The identifier of the subscription the stream processor will receive events for.</param> /// <param name="executionContext">The <see cref="ExecutionContext"/>.</param> /// <param name="eventProcessor">The event processor that writes the received events to a scoped event log.</param> /// <param name="eventsFetcher">The event fetcher that receives fetches events over an event horizon connection.</param> /// <param name="streamProcessorStates">The repository to use for getting the subscription state.</param> /// <param name="eventsFetcherPolicy">The policy around fetching events.</param> /// <param name="metrics">The system for collecting metrics.</param> /// <param name="loggerFactory">The factory for creating loggers.</param> public StreamProcessor( SubscriptionId subscriptionId, ExecutionContext executionContext, IEventProcessor eventProcessor, EventsFromEventHorizonFetcher eventsFetcher, IResilientStreamProcessorStateRepository streamProcessorStates, IEventFetcherPolicies eventsFetcherPolicy, IMetricsCollector metrics, ILoggerFactory loggerFactory) { _identifier = subscriptionId; _executionContext = executionContext; _eventProcessor = eventProcessor; _streamProcessorStates = streamProcessorStates; _eventsFetcher = eventsFetcher; _eventsFetcherPolicy = eventsFetcherPolicy; _metrics = metrics; _loggerFactory = loggerFactory; _logger = loggerFactory.CreateLogger <StreamProcessor>(); }
public ScopedFilterStreamProcessor( ChannelReader <EventLogBatch> eventLogStream, StreamProcessorId streamProcessorId, IWriteEventsToStreams eventsWriter, IResilientStreamProcessorStateRepository stateProcessorStates, TenantId tenantId, bool partitioned, StreamProcessorState currentState, ILogger logger) { _eventLogStream = eventLogStream; _streamId = streamProcessorId.EventProcessorId.Value; _eventsWriter = eventsWriter; _stateProcessorStates = stateProcessorStates; _tenantId = tenantId; _partitioned = partitioned; _logger = logger; _currentState = currentState; Identifier = streamProcessorId; }
/// <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="sourceStreamDefinition">The source stream <see cref="StreamDefinition" />.</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="executionContext">The <see cref="ExecutionContext"/> of the stream processor.</param> /// <param name="failingPartitionsFactory">The factory to use to create the <see cref="IFailingPartitions" />.</param> /// <param name="eventFetcherPolicies">The policies to use while fetching events.</param> /// <param name="streamWatcher">The <see cref="IStreamEventWatcher" />.</param> /// <param name="timeToRetryGetter">The <see cref="ICanGetTimeToRetryFor{T}" /> <see cref="StreamProcessorState" />.</param> /// <param name="logger">An <see cref="ILogger" /> to log messages.</param> public ScopedStreamProcessor( TenantId tenantId, IStreamProcessorId streamProcessorId, IStreamDefinition sourceStreamDefinition, StreamProcessorState initialState, IEventProcessor processor, IResilientStreamProcessorStateRepository streamProcessorStates, ICanFetchEventsFromPartitionedStream eventsFromStreamsFetcher, ExecutionContext executionContext, Func <IEventProcessor, ICanFetchEventsFromPartitionedStream, Func <StreamEvent, ExecutionContext>, IFailingPartitions> failingPartitionsFactory, IEventFetcherPolicies eventFetcherPolicies, IStreamEventWatcher streamWatcher, ICanGetTimeToRetryFor <StreamProcessorState> timeToRetryGetter, ILogger logger) : base(tenantId, streamProcessorId, sourceStreamDefinition, initialState, processor, eventsFromStreamsFetcher, executionContext, eventFetcherPolicies, streamWatcher, logger) { _streamProcessorStates = streamProcessorStates; _failingPartitions = failingPartitionsFactory(processor, eventsFromStreamsFetcher, GetExecutionContextForEvent); _timeToRetryGetter = timeToRetryGetter; }
/// <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; }