public AuditIngestionComponent(
            Settings settings,
            IDocumentStore documentStore,
            RawEndpointFactory rawEndpointFactory,
            LoggingSettings loggingSettings,
            BodyStorageFeature.BodyStorageEnricher bodyStorageEnricher,
            IEnrichImportedAuditMessages[] enrichers,
            AuditIngestionCustomCheck.State ingestionState
            )
        {
            var errorHandlingPolicy = new AuditIngestionFaultPolicy(documentStore, loggingSettings, FailedMessageFactory, OnCriticalError);

            auditPersister = new AuditPersister(documentStore, bodyStorageEnricher, enrichers);
            var ingestor = new AuditIngestor(auditPersister, settings);

            var ingestion = new AuditIngestion(
                (messageContext, dispatcher) => ingestor.Ingest(messageContext),
                dispatcher => ingestor.Initialize(dispatcher),
                settings.AuditQueue, rawEndpointFactory, errorHandlingPolicy, OnCriticalError);

            failedImporter = new ImportFailedAudits(documentStore, ingestor, rawEndpointFactory);

            watchdog = new Watchdog(ingestion.EnsureStarted, ingestion.EnsureStopped, ingestionState.ReportError,
                                    ingestionState.Clear, settings.TimeToRestartAuditIngestionAfterFailure, log, "failed message ingestion");
        }
        public AuditIngestionComponent(
            Settings settings,
            IDocumentStore documentStore,
            RawEndpointFactory rawEndpointFactory,
            LoggingSettings loggingSettings,
            BodyStorageFeature.BodyStorageEnricher bodyStorageEnricher,
            IEnrichImportedAuditMessages[] enrichers,
            AuditIngestionCustomCheck.State ingestionState
            )
        {
            this.settings = settings;
            var errorHandlingPolicy = new AuditIngestionFaultPolicy(documentStore, loggingSettings, FailedMessageFactory, OnCriticalError);

            auditPersister = new AuditPersister(documentStore, bodyStorageEnricher, enrichers);
            ingestor       = new AuditIngestor(auditPersister, settings);

            var ingestion = new AuditIngestion(
                async(messageContext, dispatcher) =>
            {
                var taskCompletionSource = new TaskCompletionSource <bool>(TaskCreationOptions.RunContinuationsAsynchronously);
                messageContext.SetTaskCompletionSource(taskCompletionSource);

                await channel.Writer.WriteAsync(messageContext).ConfigureAwait(false);
                await taskCompletionSource.Task.ConfigureAwait(false);
            },
                dispatcher => ingestor.Initialize(dispatcher),
                settings.AuditQueue, rawEndpointFactory, errorHandlingPolicy, OnCriticalError);

            failedImporter = new ImportFailedAudits(documentStore, ingestor, rawEndpointFactory);

            watchdog = new Watchdog(ingestion.EnsureStarted, ingestion.EnsureStopped, ingestionState.ReportError,
                                    ingestionState.Clear, settings.TimeToRestartAuditIngestionAfterFailure, log, "failed message ingestion");

            channel = Channel.CreateBounded <MessageContext>(new BoundedChannelOptions(settings.MaximumConcurrencyLevel)
            {
                SingleReader = true,
                SingleWriter = false,
                AllowSynchronousContinuations = false,
                FullMode = BoundedChannelFullMode.Wait
            });

            ingestionWorker = Task.Run(() => Loop(), CancellationToken.None);
        }
Exemplo n.º 3
0
 public AuditIngestor(AuditPersister auditPersister, Settings settings)
 {
     this.auditPersister = auditPersister;
     this.settings       = settings;
 }
Exemplo n.º 4
0
 public AuditIngestor(AuditPersister auditPersister, IForwardMessages messageForwarder, Settings settings)
 {
     this.auditPersister   = auditPersister;
     this.messageForwarder = messageForwarder;
     this.settings         = settings;
 }