/// <summary> /// Initializes a new instance of <see cref="EventHandler"/>. /// </summary> /// <param name="streamProcessors">The <see cref="IStreamProcessors" />.</param> /// <param name="filterValidationForAllTenants">The <see cref="IValidateFilterForAllTenants" /> for validating the filter definition.</param> /// <param name="streamDefinitions">The<see cref="IStreamDefinitions" />.</param> /// <param name="arguments">Connecting arguments.</param> /// <param name="filterProcessorForTenant"></param> /// <param name="eventProcessorForTenant">The event processor.</param> /// <param name="acceptRegistration">Accepts the event handler registration.</param> /// <param name="rejectRegistration">Rejects the event handler registration.</param> /// <param name="logger">Logger for logging.</param> /// <param name="executionContext">The execution context for the event handler.</param> /// <param name="cancellationToken">Cancellation token that can cancel the hierarchy.</param> public EventHandler( IStreamProcessors streamProcessors, IValidateFilterForAllTenants filterValidationForAllTenants, IStreamDefinitions streamDefinitions, EventHandlerRegistrationArguments arguments, Func <TenantId, IFilterProcessor <TypeFilterWithEventSourcePartitionDefinition> > filterProcessorForTenant, Func <TenantId, IEventProcessor> eventProcessorForTenant, Func <CancellationToken, Task> acceptRegistration, Func <Failure, CancellationToken, Task> rejectRegistration, ILogger logger, ExecutionContext executionContext, CancellationToken cancellationToken) { _logger = logger; _streamProcessors = streamProcessors; _filterValidator = filterValidationForAllTenants; _streamDefinitions = streamDefinitions; _arguments = arguments; _filterProcessorForTenant = filterProcessorForTenant; _executionContext = executionContext; _eventProcessorForTenant = eventProcessorForTenant; _acceptRegistration = acceptRegistration; _rejectRegistration = rejectRegistration; _cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); }
/// <inheritdoc /> public IEventHandler Create(EventHandlerRegistrationArguments arguments, ReverseCallDispatcher dispatcher, CancellationToken cancellationToken) => new EventHandler( _streamProcessors, _filterValidator, _streamDefinitions, arguments, tenant => new TypeFilterWithEventSourcePartition( arguments.Scope, new TypeFilterWithEventSourcePartitionDefinition(StreamId.EventLog, arguments.EventHandler.Value, arguments.EventTypes, arguments.Partitioned), _getEventsToStreamsWriter(tenant), _loggerFactory.CreateLogger <TypeFilterWithEventSourcePartition>()), _ => new EventProcessor(arguments.Scope, arguments.EventHandler, dispatcher, _loggerFactory.CreateLogger <EventProcessor>()), cancellation => dispatcher.Accept(new EventHandlerRegistrationResponse(), cancellation), (failure, cancellation) => dispatcher.Reject(new EventHandlerRegistrationResponse { Failure = failure.ToProtobuf() }, cancellation), _loggerFactory.CreateLogger <EventHandler>(), arguments.ExecutionContext, cancellationToken );
/// <inheritdoc /> public FastEventHandler CreateFast(EventHandlerRegistrationArguments arguments, bool implicitFilter, ReverseCallDispatcher dispatcher, CancellationToken cancellationToken) => new(