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
考虑支持 maxRequests、maxRequestsPerHost 的配置吗 #111
Comments
确实可以考虑扩充一些配置参数。 请问下maxRequests、maxRequestsPerHost 怎么设置到OkHttp的?我在Builder类上没找到 |
在Dispatcher中设置,需要自定义初始化 Dispatcher,如下: int maxRequests = 100;
ExecutorService dispatchExecutor = new ThreadPoolExecutor(5, maxRequests, 60, TimeUnit.SECONDS,
new SynchronousQueue<>(), Util.threadFactory("OkHttp Dispatcher XXX", false), new ThreadPoolExecutor.DiscardPolicy());
Dispatcher dispatcher = new Dispatcher(dispatchExecutor);
dispatcher.setMaxRequests(maxRequests);
dispatcher.setMaxRequestsPerHost(maxRequests); Builder的dispatcher(dispatcher)方法传进去就行了。 |
https://github.com/LianjiaTech/retrofit-spring-boot-starter/releases/tag/2.3.3 2.3.3版本重构了自定义OkHttpClient属性。你这个需求可以自行注入支持了。具体看文档: |
@chentianming11 我目前是自己注入的OkHttpClient,想着如果可以通过配置文件实现,就更加优雅便捷。 |
目前配置改成了基于Bean的方式做的,你可以自行注入配置文件属性来创建OkHttpClient。这样就可以在配置文件配置了。
框架就不统一做了,因为属性太多且复杂,收益也不大。
…---原始邮件---
发件人: ***@***.***>
发送时间: 2022年5月25日 00:34:09
收件人: ***@***.***>;
抄送: ***@***.******@***.***>;
主题: Re: [LianjiaTech/retrofit-spring-boot-starter] 考虑支持 maxRequests、maxRequestsPerHost 的配置吗 (Issue #111)
@chentianming11 我目前是自己注入的OkHttpClient,想着如果可以通过配置文件实现,就更加优雅便捷。
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
内部服务之间用OKHTTP调用,默认的maxRequests、maxRequestsPerHost太小限制了并发量,生产环境对这2个参数做了调整后效果还是比较明显;retrofit-spring-boot-starter 虽然可以用代码自定义注入OkHttpClient并做很多自定义配置,但是不够优雅便捷。
The text was updated successfully, but these errors were encountered: