/// <inheritdoc/> public async Task <IDictionary <TenantId, FilterValidationResult> > Validate <TDefinition>(Func <IFilterProcessor <TDefinition> > getFilterProcessor, CancellationToken cancellationToken) where TDefinition : IFilterDefinition { var result = new Dictionary <TenantId, FilterValidationResult>(); await _onAllTenants.PerformAsync(async tenantId => { _logger.Debug("Validating Filter for Tenant '{Tenant}'", tenantId); var filterProcessor = getFilterProcessor(); var filterId = filterProcessor.Definition.TargetStream; _logger.Trace("Trying to get definition of Filter '{Filter}' for Tenant '{Tenant}'", filterId, tenantId); var tryGetFilterDefinition = await _getFilterDefinitions().TryGetFromStream(filterProcessor.Scope, filterId, cancellationToken).ConfigureAwait(false); if (tryGetFilterDefinition.Success) { _logger.Trace("Validating Filter '{Filter}' for Tenant '{Tenant}'", filterId, tenantId); var validationResult = await _filterValidators.Validate(tryGetFilterDefinition.Result, filterProcessor, cancellationToken).ConfigureAwait(false); result.Add(tenantId, validationResult); } else { _logger.Debug("Could not get definition of Filter '{Filter}' for Tenant '{Tenant}'", filterId, tenantId); result.Add(tenantId, new FilterValidationResult()); } }).ConfigureAwait(false); return(result); }
/// <summary> /// Initializes the stream processor. /// </summary> /// <returns>A <see cref="Task" />that represents the asynchronous operation.</returns> public async Task Initialize() { _logger.Debug("Initializing StreamProcessor with Id: {StreamProcessorId}", _identifier); _externalCancellationToken.ThrowIfCancellationRequested(); if (_initialized) { throw new StreamProcessorAlreadyInitialized(_identifier); } await _onAllTenants.PerformAsync(async tenant => { var scopedStreamProcessorsCreators = _getScopedStreamProcessorsCreator(); var scopedStreamProcessor = await scopedStreamProcessorsCreators.Create( _streamDefinition, _identifier, _getEventProcessor(), _externalCancellationToken).ConfigureAwait(false); _streamProcessors.Add(tenant, scopedStreamProcessor); }).ConfigureAwait(false); _initialized = true; }
/// <inheritdoc/> public Task Persist(ScopeId scope, IStreamDefinition streamDefinition, CancellationToken cancellationToken) => _onAllTenants.PerformAsync(_ => _getStreamDefinitions().Persist(scope, streamDefinition, cancellationToken));