如何将HTTPCLIENT与第三方LIB一起使用?
示例初始情况:
可以说我有一个带有依赖注入的Web API。 我通常会将一个httpclient绑定为单身人士。
我认为httpclient被认为主要是线程安全。
https://codereview.stackexchange.com/questions/questions/questions/questions/6999950/single-instance/single-instance/single-instance/single-instance/single-instance/single-instance/single-instance/可重复使用的httpclient
(最佳答案 - 三个链接),
但是有些成员不像“ Baseaddress”那样不可变。
我们应该如何使用需要httpclient作为依赖性的第三方利率?
第三方LIB可以使用线程安全方法或更改不变的成员。
我应该为每个第三方lib创建一个客户吗?
假设第三方LIB会以“正确”方式使用HTTPCLEINT是“保存”吗?
PS在Stackoverflow上问的第二个问题。请不要杀了我问。
Example initial situation:
Lets say I have a web api with dependency injection.
I normally would bind one HttpClient as singleton.
I think the HttpClient is regarded as mostly thread-safe.
https://codereview.stackexchange.com/questions/69950/single-instance-of-reusable-httpclient
(top answer - the three links)
But some member are not immutable like the 'BaseAddress'.
How should we use third-party-libs that need a HttpClient as dependency?'
The third-party-lib could use not thread-safe methods or change the not immutable members.
Should I create one client for every third-party-lib?
Is it 'save' to assume that the third-party-lib will use the HttpClient in the 'correct' way?
p.s second question asked on stackoverflow. Please don't kill me for asking.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论