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

I would like Policy to be injectible #22

Closed
jwconway opened this issue Jan 21, 2015 · 3 comments
Closed

I would like Policy to be injectible #22

jwconway opened this issue Jan 21, 2015 · 3 comments

Comments

@jwconway
Copy link

I love Polly but i dont like having to have hard coded references to Polly all over my code base. I wonder if you would consider making Policy injectible, maybe by publishing an IPolicy interface?

This would allow me do decouple your implementation from my code easier and i can inject Circuit Breakers into my services.

Ive blogged here (mentioned by Scott Hanselman) about how i solved this issue, but i think it could be made easier.

@michael-wolfenden
Copy link
Contributor

James,

If I provided an IPolicy interface, you would still have references to Polly all over your code base.

The point of decoupling is to shield your code from third party code. To do this, you would create the interface that your code relies on (IPolicy) and then implement it using Polly (as you have done), or some other exception handling library.

The point is that your code only knows about your own interface which you inject everywhere. You could use some other library, and your code would not care. If I defined an IPolicy that you used everywhere and you wanted to change libraries, you are stuck.

Does this make sense?

@jwconway
Copy link
Author

It absolutely makes sense yes. In fact this is exactly how we have implemented it.

Cheers, keep up the good work 👍

@michael-wolfenden
Copy link
Contributor

James,

Much appreciated, I'm glad you are enjoying the library.

Regards

Michael

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

No branches or pull requests

2 participants