-
Notifications
You must be signed in to change notification settings - Fork 46
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
Non-static client factory #99
base: main
Are you sure you want to change the base?
Conversation
@vladsandu any chance you can have a look? |
Hey @mburumaxwell sorry for the delay -- we'll take a look. Vlad no longer works at Wildbit. |
@mburumaxwell is there a specific problem the current interface/design is causing for you that you are trying to solve with this PR? While it is true that HttpClient should be re-used, and it is also true that MS docs currently suggest creating clients from IHttpClientFactory, I'm not sure this change is worth the risk imposed, and the testing effort that would be required. |
@jchoca the intention is to inject the client using instances form IHttpClientFactory which brings a couple of benefits, including logging. I just thought it would be better to do a different PR for the dependency injection scenario. |
What would that other PR consist of? |
@mburumaxwell - |
Unfortunately, that doesn't work well with a dependency injection. It requires a lot of effort to setup get |
Fair enough, I understand your concern. However, conformance to a DI mechanism is not a strong enough reason to make this change. |
@Archanian could you explain how you arrived at the decision for "not a strong enough reason"? For clarity purposes, what would break or not work as expected? |
Microsoft advises that we should
IHttpClientFactory
to implement resilient HTTP requests (see docs). For this to happen, theHttpClient
needs to be provided when creating instances ofPostmarkClient
orPostmarkAdminClient
.In this PR, the static client factory is replaced with an optional
ISimpleHttpClient
parameter. This works for scenarios where the injection ofHttpClient
instances is (and is not) preferred.