-
Notifications
You must be signed in to change notification settings - Fork 0
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
Current PollyNator output may not play well for Interface containing both sync and async overloads #3
Comments
@reisenberger Actually I had actually originally created a constructor that accepted two different Policy types, and then each of the helper methods tested if one was null, and executed the one that wasn't, so such code is perfectly possible to generate. It is also possible to test if all methods return a Task, or not. It does make the resulting code less... elegant... to use, but, as that is the current state of play with Polly, then I will update Pollynator to support these scenarios. |
Thinking aloud, mostly for my own benefit (I am the type of developer who draws a lot when looking at code, and this is the next best thing).... Logic to implement as per current discussion
A consideration: Problem - Dealing with changes to APIs. Regenerating code if an interface changes (e.g. an async method is introduced, where one was not present before, or, all methods becoming async), will result in adjusting the signature of an existing constructor. It would also require adding or removing a helper method, that could have been customised. Not rocket science, but does create some spaghetti in the Pollynator codebase. Such changes could become confusing to the developer, and bearing in mind the current discussion on unifying the sync and async approaches in Polly, it would soon (timescale?) be redundant anyway. Alternative approach 1 Assumption: Most methods will be To avoid having additional logic that adds and removes code, and planning for the 'vNext' Polly, adopt the following approach:
Alternative approach 2 Assumption: Most methods will be
Alternative approach 3 Assumption: Most methods will be
Alternative approach 4 Mark this project as a beta work in progress, pending Polly vNext, depending on ETA. Personally, I am leaning towards Alternative Approach 3. Chopping and changing existing code would undermine the simplicity of Final decision to be made after further discussion on App-vNext/Polly#281 NOTE TO SELF: Examine using Roslyn to comment out existing methods rather than altering / removing them, to preserve customisations. Also look at adding an Obsolete attribute to methods during generation / regeneration. |
Hi @mcquiggd . To help plan, timescales for Polly#281 realistically in weeks, not days. If we can sufficiently define the solution tho, we could up-for-grabs it (which could bring it forward). Or I could model it for one policy type, and we up-for-grabs the remainder ... Have raised this up the priority tree, in view of the impact on Pollynator! |
Clear... in that case I will implement Alternative Approach 3 from my message above, and implement two constructors this weekend, with attendant explanation, and a I might have time to assist with the changes to Polly... David |
Have reviewed the functionality of Pollynator (love the name) as described in the readme. One potential wrinkle: Polly currently requires separate policy instances for sync and async executions.
From the readme, PollyNator generates:
If
ITestInterface
contains both sync and async methods, a singlePolicyWrap polly
cannot be used to execute both: either the sync or the async executions will throw.(This is a less-than-ideal design element in Polly, dating from prior to App-vNext stewardship. The blog post discusses factors affecting. A proposal within Polly seeks views whether to change this.)
Given this restriction in current Polly, PollyNator could:
PolicyWrap policy
PolicyWrap asyncPolicy
PolicyWrap syncPolicy, PolicyWrap asyncPolicy
(only thoughts - you may have other ideas!)
The text was updated successfully, but these errors were encountered: