-
-
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
Make the constructors of the Policy abstract base classes protected, not internal [allow custom policies] #298
Comments
Please see pull request #299. Note that I have made more changes than this Issue suggested:
I've added comments for the newly-public constructors/methods/properties. |
This at least provides the option to consumers of Polly to do so. However,
I think it is an anti-pattern to extend an external API and expose its
implementation throughout your code - even when doing so thru interfaces.
Rather, it should be abstracted away and wrapped so the 3rd party API could
be swapped at some future point.
…On Aug 18, 2017 5:58 PM, "reisenberger" ***@***.***> wrote:
The constructors of the Policy and Policy<TResult> abstract base classes
are internal but should be made public.
This would allow users to implement new custom policies, outside of the
Polly package, deriving from these base classes.
Needed in files Policy.cs, Policy.TResult.cs, PolicyAsync.cs,
PolicyAsync.TResult.cs.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#298>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAoC9hRppZ0av9iaA8rHm0s0kiirxqnaks5sZhcigaJpZM4O8H9p>
.
|
@udlose Agreed, but this is how it is currently setup. Imho, I believe if you are architecting your own solution with the ability to swap the 3rd party API (Polly) out at any point in time, which is a great idea obviously, then you'd probably have to create an abstraction for the concept of 'policies' for your own application, e.g. a policy provider with a specific implementation that uses, and optionally implements additional, Polly policies. My 2 cents. |
@ExtRemo75 - yes, you will have to somehow abstract usages of policies. I was thinking of doing so via aggregation instead of inheritence. Though, I guess it's a matter of preference. Based on my experience, i've had more success using aggregation than inheritance to isolate 3rd party APIs. |
Thanks all for all the great comments. Hoping to come back to this and #299 before the end of the week. |
@udlose @ExtRemo75 Great discussion re aggregation rather than inheritance for isolating 3rd party APIs. I guess it depends what you are trying to achieve. If you want to isolate Polly, then yes, wrapping in your own abstractions is the way to go. The benefit of allowing people to extend the The fact that all this functionality is loaded on the We would be very happy to see anyone's ideas though - we can also make incremental change. The current approach is targeting incremental change - some of it quite significant (eg #281) - where the existing architecture is actively holding us back. Keep the thoughts coming, as we have opportunities to change the architecture with v6. |
Closed by #391 The options for compenentisation discussed in the previous comment (thanks for the valuable discussion) remain options for a future version of Polly or any similar product. As discussed above, a rewrite to such a structure would be intellectually well motivated (and does appeal). It would require a significant chunk of time tho (and would lead to a significantly different syntax experience for users). ( EDIT: Very happy to discuss any ideas around this, and/or support anyone who wants to explore them. ) |
The constructors of the
Policy
andPolicy<TResult>
abstract base classes areinternal
but should be madepublicprotected
.This would allow users to implement new custom policies, outside of the Polly package, deriving from these base classes.
Needed in files
Policy.cs
,Policy.TResult.cs
,PolicyAsync.cs
,PolicyAsync.TResult.cs
.The text was updated successfully, but these errors were encountered: