public ChangeFeedProcessor( IChangeFeedRetrieveService changeFeedRetrieveService, IFhirTransactionPipeline fhirTransactionPipeline, ISyncStateService syncStateService, IExceptionStore exceptionStore, ILogger <ChangeFeedProcessor> logger) { EnsureArg.IsNotNull(changeFeedRetrieveService, nameof(changeFeedRetrieveService)); EnsureArg.IsNotNull(fhirTransactionPipeline, nameof(fhirTransactionPipeline)); EnsureArg.IsNotNull(syncStateService, nameof(syncStateService)); EnsureArg.IsNotNull(logger, nameof(logger)); _changeFeedRetrieveService = changeFeedRetrieveService; _fhirTransactionPipeline = fhirTransactionPipeline; _syncStateService = syncStateService; _exceptionStore = exceptionStore; _logger = logger; }
public static async Task SynchronizePropertiesAsync <T>(T component, FhirTransactionContext context, Action <T, FhirTransactionContext> synchronizeAction, bool requiredProperty, bool enforceAllFields, IExceptionStore exceptionStore, CancellationToken cancellationToken = default) { EnsureArg.IsNotNull(context, nameof(context)); EnsureArg.IsNotNull(synchronizeAction, nameof(synchronizeAction)); EnsureArg.IsNotNull(exceptionStore, nameof(exceptionStore)); try { synchronizeAction(component, context); } catch (DicomTagException ex) { if (!enforceAllFields && !requiredProperty) { await exceptionStore.WriteExceptionAsync( context.ChangeFeedEntry, ex, ErrorType.DicomValidationError, cancellationToken); } else { throw; } } }
public static async Task SynchronizePropertiesAsync <T>(T component, FhirTransactionContext context, Action <T, FhirTransactionContext> synchronizeAction, bool requiredProperty, bool partialValidation, IExceptionStore exceptionStore, CancellationToken cancellationToken = default) { try { synchronizeAction(component, context); } catch (DicomTagException ex) { if (partialValidation && !requiredProperty) { await exceptionStore.WriteExceptionAsync( context.ChangeFeedEntry, ex, ErrorType.DicomValidationError, cancellationToken); } else { throw; } } }
public RetryableFhirTransactionPipeline(IFhirTransactionPipeline fhirTransactionPipeline, IExceptionStore exceptionStore) : this( fhirTransactionPipeline, exceptionStore, MaxRetryCount) { }
public RetryableFhirTransactionPipeline(IFhirTransactionPipeline fhirTransactionPipeline, IExceptionStore exceptionStore, IOptions <RetryConfiguration> retryConfiguration) { EnsureArg.IsNotNull(fhirTransactionPipeline, nameof(fhirTransactionPipeline)); EnsureArg.IsNotNull(exceptionStore, nameof(exceptionStore)); EnsureArg.IsNotNull(retryConfiguration, nameof(retryConfiguration)); _fhirTransactionPipeline = fhirTransactionPipeline; _exceptionStore = exceptionStore; _timeoutPolicy = Policy.TimeoutAsync(retryConfiguration.Value.TotalRetryDuration); _retryPolicy = Policy .Handle <RetryableException>() .WaitAndRetryForeverAsync( (retryAttempt, exception, context) => { return(TimeSpan.FromSeconds(Math.Min(60, Math.Pow(2, retryAttempt)))); }, (exception, retryCount, timeSpan, context) => { var changeFeedEntry = (ChangeFeedEntry)context[nameof(ChangeFeedEntry)]; return(_exceptionStore.WriteRetryableExceptionAsync( changeFeedEntry, retryCount, timeSpan, exception)); }); }