internal RetryableFhirTransactionPipeline( IFhirTransactionPipeline fhirTransactionPipeline, IExceptionStore exceptionStore, int maxRetryCount) { EnsureArg.IsNotNull(fhirTransactionPipeline, nameof(fhirTransactionPipeline)); EnsureArg.IsNotNull(exceptionStore, nameof(exceptionStore)); _fhirTransactionPipeline = fhirTransactionPipeline; _exceptionStore = exceptionStore; _retryPolicy = Policy .Handle <RetryableException>() .WaitAndRetryAsync( maxRetryCount, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (exception, timeSpan, retryCount, context) => { ChangeFeedEntry changeFeedEntry = (ChangeFeedEntry)context[nameof(ChangeFeedEntry)]; return(_exceptionStore.WriteRetryableExceptionAsync( changeFeedEntry, retryCount, exception)); }); }
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)); }); }