Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Polly instead of EnterpriseLibrary #169 #313

Closed
wants to merge 2 commits into from

Conversation

meikeric
Copy link
Contributor

@meikeric meikeric commented Jan 4, 2019

Description

Changed out EnterpriseLibrary transient error retry for Polly

Related issues

Addresses [issue #169].

Testing

All the unit tests pass. Per Polly documentation, there is not way to individual unit test Polly.

@msftclas
Copy link

msftclas commented Jan 4, 2019

CLA assistant check
All CLA requirements met.

@@ -21,19 +22,20 @@ public RetryExceptionPolicyFactory(CosmosDataStoreConfiguration configuration)
EnsureArg.IsNotNull(configuration, nameof(configuration));

_maxNumberOfRetries = configuration.RetryOptions.MaxNumberOfRetries;
_minWaitTime = TimeSpan.FromSeconds(Math.Min(RetryStrategy.DefaultMinBackoff.TotalSeconds, configuration.RetryOptions.MaxWaitTimeInSeconds));
_minWaitTime = TimeSpan.FromSeconds(configuration.RetryOptions.MinWaitTimeInSeconds);
_maxWaitTime = TimeSpan.FromSeconds(configuration.RetryOptions.MaxWaitTimeInSeconds);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like both _minWaitTime and _maxWaitTime are unused now. If so these vars can be removed

@@ -98,7 +98,7 @@ public sealed class FhirDataStore : IDataStore, IProvideCapability
_logger.LogDebug($"Upserting {resource.ResourceTypeName}/{resource.ResourceId}, ETag: \"{weakETag?.VersionId}\", AllowCreate: {allowCreate}, KeepHistory: {keepHistory}");

UpsertWithHistoryModel response = await _retryExceptionPolicyFactory.CreateRetryPolicy().ExecuteAsync(
async () => await _upsertWithHistoryProc.Execute(
async (ct) => await _upsertWithHistoryProc.Execute(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused param. Either remove like below or look at adding/passing through the CancellationToken in the Execute function.

Suggested change
async (ct) => await _upsertWithHistoryProc.Execute(
async _ => await _upsertWithHistoryProc.Execute(

_maxWaitTime,
RetryStrategy.DefaultClientBackoff);
var policy = Policy
.Handle<Exception>(RetryExceptionPolicy.IsTransient)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably take more advantage of Polly here and handle DocumentClientException specifically.

@brendankowitz
Copy link
Member

Updating and moving to #369

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants