-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Async sleep + continue on captured ctx. Fixes #49 #53
Conversation
@michael-wolfenden any updates on this? |
@yevhen Looking at your PR, I see (only now...) that you have also tackled async sleep as |
@reisenberger ye, think the same! |
/// <param name="continueOnCapturedContext">Whether to continue on a captured synchronization context.</param> | ||
/// <returns>The policy instance.</returns> | ||
public static Policy RetryAsync(this PolicyBuilder policyBuilder, bool continueOnCapturedContext) | ||
{ | ||
return policyBuilder.RetryAsync(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yevhen This overload RetryAsync(this PolicyBuilder policyBuilder, bool continueOnCapturedContext)
doesn't make use of the supplied continueOnCapturedContext
value. Does it want a small correction to:
return policyBuilder.RetryAsync(1, continueOnCapturedContext);
?
(Apologies @yevhen @joelhulen for intervening but hope useful - I spotted this while doing some exploratory investigation of how to add cancellation support!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@reisenberger No apology needed! It takes volunteers like you to help spot these things and keep progress marching forward. All help is gladly accepted :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joelhulen +1 @reisenberger nice catch! I was trying really hard to not introduce breaking changes and got lost with all those pesky overloads. Many thanks and you don't need to apologize for that. It's great to have another pair of eyes! 👀
@yevhen @joelhulen On the subject of all those overloads (agree), it might be worth some forethought - if we are going to introduce both In the retry overloads in this #53, @yevhen @joelhulen (see snip below) ... ... I like the order in
If/when introducing
(or cancellation token / captured context in the other order) |
Very good suggestion. I will update PR. re order of CancellationToken/ContinueOnCapturedContext I think any order is fine. The more important is to figure out what to do with all those overloads? If we introduce another set of overloads (permutation with What if we introduce something like Parameter Object? Alternatively we can try to employ automation, say T4 template which will auto-generate overloads with all that currently copy-n-pasted xml documentation. |
@yevhen Thanks for this great contribution; we're looking to get this merged soon. Re overloads I can see three options, not sure if any quite come together (tho if anyone can see a bright way through this conundrum, please shout) Optional parameters: Would be ideal (my preferred) if it weren't for the caller/call-ee problem in how this is implemented in C#. IE if we later have to change signature, can cause run-time failure if people just drop in new DLL rather than recompile against. Believe why most of .NET framework doesn't use optional params. T4: Slight concern about introducing something lesser-known which may raise the barrier of entry for other contributors. Also, does this just help with documentation (eg xml comments)? Parameter object: Problem I can see is there's already the optional Also, |
@yevhen Thanks again for this important PR! Unless anyone has brighter idea on overloads, team AppvNext are ready to accept/merge. Are you able to update the PR with the following minor adjustments? - then it will be good to go!
Thank you! |
@@ -10,7 +10,7 @@ namespace Polly.CircuitBreaker | |||
{ | |||
internal partial class CircuitBreakerPolicy | |||
{ | |||
internal static async Task ImplementationAsync(Func<Task> action, IEnumerable<ExceptionPredicate> shouldRetryPredicates, ICircuitBreakerState breakerState) | |||
internal static async Task ImplementationAsync(bool continueOnCapturedContext, Func<Task> action, IEnumerable<ExceptionPredicate> shouldRetryPredicates, ICircuitBreakerState breakerState) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Request move bool continueOnCapturedContext
to be last parameter, in ImplementationAsync
If you're ready to publish new Nuget package then I'm ready to update this 2015-12-10 1:26 GMT+02:00 reisenberger notifications@github.com:
|
/// <returns>The policy instance.</returns> | ||
/// <remarks>(see "Release It!" by Michael T. Nygard fi)</remarks> | ||
/// <exception cref="System.ArgumentOutOfRangeException">exceptionsAllowedBeforeBreaking;Value must be greater than zero.</exception> | ||
public static Policy CircuitBreakerAsync(this PolicyBuilder policyBuilder, int exceptionsAllowedBeforeBreaking, TimeSpan durationOfBreak) | ||
public static Policy CircuitBreakerAsync(this PolicyBuilder policyBuilder, int exceptionsAllowedBeforeBreaking, TimeSpan durationOfBreak, bool continueOnCapturedContext = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Request add overload, not optional parameter, because of optional-params-compiled-at-callee-not-caller problem in c# implementation of optional parameters
@yevhen Once I merge your PR (after your changes), then I'll test locally and publish the new NuGet package once verified. |
/// <param name="continueOnCapturedContext">Whether to continue on a captured synchronization context.</param> | ||
/// <param name="sleepDurations">The sleep durations to wait for on each retry.</param> | ||
/// <returns>The policy instance.</returns> | ||
public static Policy WaitAndRetryAsync(this PolicyBuilder policyBuilder, bool continueOnCapturedContext, IEnumerable<TimeSpan> sleepDurations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per previous discussion, move bool continueOnCapturedContext
to after sleepDurations
( @yevhen / all, apologies, and thanks, for bearing with flurry of line notes ) ( as you rightly say, yevhen, large number of overloads ...;) But purpose: If we fix parameter order appropriately now, the cancellation support #46 can be built right around this without any breaking changes to the API between releases |
@yevhen: We're ready to include your PR into version 3.0! This along with cancellation features @nedstoyanov and @reisenberger are working on will really help make Polly even more mature. Thank you so much for helping us push the library forward. If you are ready, please fix the parameter order, as outlined in detail by @reisenberger. Once that's done, we can merge it in. |
Sorry, guys. I'll definitely do this till EOW. At the moment I'm incredibly busy, preparing for 2 public presentations this week. |
Thanks, @yevhen! I hope you know I wasn't trying to pressure you. It's a crazy a time of year for all of us. |
No worries )) 2015-12-16 21:18 GMT+02:00 Joel Hulen notifications@github.com:
|
@yevhen: Hope you had a great holiday weekend :) Just wondering if you've had a chance to fix up those last few things? We're hoping to release a new version with your changes by year's end, if possible. Also, just so you're aware, you'll need to rebase your local repo with the latest changes we incorporated yesterday. Thanks! |
@yevhen @joelhulen Super: it was my absolute assumption that we would want to be completely deterministic about this across the library, but wanted to involve you guys. @yevhen : those two:
... appear to the only two not currently controlling the synchonization context ( |
guys, what do you have set for Git's core.autocrlf and what version of git do you have installed? I'm observing absolutely weird behavior with files being modified just after the clone, despite having core.autocrlf=false. I'm using Git v1.9.5. |
I've seen cr/lf oddness too but don't know the setting - over to @joelhulen ? - would be good to iron this out. |
Apologies - more thoughts coming on this: Because of the way the codebase has evolved (see end of post), we now have / are working towards a number of constructs in the codebase like / effectively equivalent to: [+]
or
Can these not just be shortened to (It could also have the advantage of explicitly configuring the await either way - it probably makes no practical difference in the current .NET implementation, but may be clearer to subsequent code readers what is going on.) The history of this in the Polly library was: (from memory- could be wrong on some detail)
(with apologies again for late additional realisation ... what do you guys think?) |
@reisenberger ye, NotOnCapturedContext() doesn't make much sense anymore. I'll incorporate this realization ;) |
I do believe problems with line endings are due to use of .gitattributes file. I observed similar problems on my projects when this file was included. It needs to be deleted from source. It only creates more problems. |
I've added all change requests as separate commits so it should be easy to review. If you want I can squash everything into single commit. |
Hey, build failed for some weird reasons. Please kick a rebuild. |
@yevhen there were some build failures yesterday due to connectivity issues between appveyor and NuGet. I'll kick off another build. |
Build succeeded :) |
Awesome! =) |
Ah, I forgot to modify CHANGELOG. Tomorrow then. Can you do it? )) |
I can modify the CHANGELOG if you haven't already. |
@reisenberger @yevhen: I just posted instructions on fixing the line endings to our wiki site. See if these steps help. If not, feel free to update the page :) |
@yevhen Thanks for your exemplary clear presentation! (a standard for us to follow 😄 ). Have been a good second pair of 👀 and @joelhulen looks good to go to me! Many thanks yevhen for tracking all that detail... |
Async sleep + continue on captured ctx. Fixes #49
That would be great, cause I'm out of city till 10th of January 😄
|
Thanks guys! It was a pleasure working with you on this PR. Keep it up!
|
Awesome! That would be great addition!
|
No description provided.