Beispiel #1
0
 public RetryableFhirTransactionPipeline(IFhirTransactionPipeline fhirTransactionPipeline)
     : this(
         fhirTransactionPipeline,
         MaxRetryCount,
         retryCount => retryCount == 0 ? TimeSpan.Zero : SleepDuration)
 {
 }
Beispiel #2
0
        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));
            });
        }
Beispiel #3
0
 public RetryableFhirTransactionPipeline(IFhirTransactionPipeline fhirTransactionPipeline, IExceptionStore exceptionStore)
     : this(
         fhirTransactionPipeline,
         exceptionStore,
         MaxRetryCount)
 {
 }
Beispiel #4
0
        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));
            });
        }
        public LoggingFhirTransactionPipeline(
            IFhirTransactionPipeline fhirTransactionPipeline,
            ILogger <LoggingFhirTransactionPipeline> logger)
        {
            EnsureArg.IsNotNull(fhirTransactionPipeline, nameof(fhirTransactionPipeline));
            EnsureArg.IsNotNull(logger, nameof(logger));

            _fhirTransactionPipeline = fhirTransactionPipeline;
            _logger = logger;
        }
Beispiel #6
0
        internal RetryableFhirTransactionPipeline(
            IFhirTransactionPipeline fhirTransactionPipeline,
            int retryCount,
            Func <int, TimeSpan> sleepDurationProvider)
        {
            EnsureArg.IsNotNull(fhirTransactionPipeline, nameof(fhirTransactionPipeline));

            _fhirTransactionPipeline = fhirTransactionPipeline;
            _retryPolicy             = Policy
                                       .Handle <ResourceConflictException>()
                                       .Or <ServerTooBusyException>()
                                       .WaitAndRetryAsync(retryCount, sleepDurationProvider);
        }
Beispiel #7
0
        public ChangeFeedProcessor(
            IChangeFeedRetrieveService changeFeedRetrieveService,
            IFhirTransactionPipeline fhirTransactionPipeline,
            ISyncStateService syncStateService,
            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;
            _logger = logger;
        }