private async Task LogExportJob( XEventsExportSettings.LogSourceSettings settings, CancellationToken cancellationToken) { while (true) { if (cancellationToken.IsCancellationRequested) { break; } bool bufferBlocked = (_logBuffers.TotalItemsCount >= _settings.Export.Buffer.MaxBufferSizeItemsCount); try { if (!bufferBlocked) { using (XEventExportMaster exporter = new XEventExportMaster( OnSend, null, OnErrorExportDataToBuffer )) { exporter.SetXEventsPath(settings.SourcePath); var target = new ExtendedEventsOnBuffer(_logBuffers, settings.Portion); target.SetLogSettings(settings); exporter.SetTarget(target); await exporter.StartSendEventsToStorage(cancellationToken); } } if (bufferBlocked) { await Task.Delay(100, cancellationToken); } else if (_settings.WatchMode.Use) { await Task.Delay(_settings.WatchMode.Periodicity, cancellationToken); } else { break; } } catch (Exception e) { RaiseOnError(new OnErrorExportSharedBufferEventArgs( new ExportSharedBufferException("Log export job failed.", e, settings))); await Task.Delay(60000, cancellationToken); } } }
public async Task Run(CancellationToken cancellationToken) { while (true) { if (cancellationToken.IsCancellationRequested) { break; } using (IXEventExportMaster export = new XEventExportMaster(BeforeExportData, AfterExportData, OnErrorExportData)) { export.SetXEventsPath(_settings.XEventsPath); IXEventsOnTarget target = new ExtendedEventsOnClickHouse(_settings.ConnectionString, _settings.Portion); export.SetTarget(target); await export.StartSendEventsToStorage(cancellationToken); } if (_settings.UseWatchMode) { if (cancellationToken.IsCancellationRequested) { break; } await Task.Delay(_settings.DelayMs, cancellationToken); } else { break; } if (cancellationToken.IsCancellationRequested) { break; } } }