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

fix: Changing all middlewares to use asynchronous policy execution. (fixes #232) #235

Merged
merged 2 commits into from
Jun 14, 2017

Conversation

videege
Copy link
Contributor

@videege videege commented Jun 11, 2017

Description

This changes the Polly enricher to use asynchronous policy execution. (fixes #232)

Note: I wasn't sure the best way to do this, but you might want to add some kind of detection in to reject the registration of synchronous policies, or add it to the docs.

Check List

  • [x ] All test passed.
  • Added documentation (if applicable).
  • Tests added to ensure functionality.
  • Pull Request to stable branch.

Copy link
Owner

@pardahlman pardahlman left a comment

Choose a reason for hiding this comment

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

@videege thank you for this. I tend to avoid GetAwaiter().GetResult(), see comments.

@@ -31,7 +31,7 @@ public BasicPublishMiddleware(IExclusiveLock exclusive, BasicPublishOptions opti
[RetryKey.PublishMandatory] = mandatory,
[RetryKey.BasicProperties] = basicProps,
[RetryKey.PublishBody] = body,
});
}).GetAwaiter().GetResult();
Copy link
Owner

Choose a reason for hiding this comment

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

Since we're planning to go all in, I think we should make the call to this method async. That way, we get rid of the .GetAwaiter().GetResult(). Makes sense?

{
policyName = policyName ?? PolicyKeys.DefaultPolicy;
context.Properties.TryAdd(policyName, poliocy);
context.Properties.TryAdd(policyName, policy);
Copy link
Owner

Choose a reason for hiding this comment

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

👌

contextData: new Dictionary<string, object>
{
[RetryKey.PipeContext] = context
});
}).GetAwaiter().GetResult();
Copy link
Owner

Choose a reason for hiding this comment

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

I think this method should be async

@videege
Copy link
Contributor Author

videege commented Jun 12, 2017

I agree with your comments - I'll take a look at updating the PR tonight.

@videege
Copy link
Contributor Author

videege commented Jun 14, 2017

I pushed a change making everything async - what do you think?

@pardahlman
Copy link
Owner

Looks good! Thanks!

@pardahlman pardahlman merged commit 217dbcb into pardahlman:2.0 Jun 14, 2017
@videege videege deleted the 2.0 branch June 14, 2017 15:54
@videege
Copy link
Contributor Author

videege commented Jul 11, 2017

Any chance you could push a package release including this fix?

ping @pardahlman

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.

Use of Polly causes timeout exception
2 participants