-
Notifications
You must be signed in to change notification settings - Fork 15
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
[BREAKING] feat: support loadConfig asynchronous #11
base: master
Are you sure you want to change the base?
Conversation
7514364
to
a0066ea
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #11 +/- ##
==========================================
Coverage ? 100.00%
==========================================
Files ? 6
Lines ? 33
Branches ? 0
==========================================
Hits ? 33
Misses ? 0
Partials ? 0 ☔ View full report in Codecov by Sentry. |
31caaba
to
42327b4
Compare
42327b4
to
b33ff7a
Compare
config = Object.assign({}, config, { urllib: app.httpclient }); | ||
if (is.function(config.loadConfig)) { | ||
const result = config.loadConfig(config, app); | ||
config = is.promise(result) ? (await result) : result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样直接赋值的话 client 的配置会不会覆盖 default 啊(盲猜
测试用例里好像也没体现
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样的话 default 中的异步函数由于延迟执行,会覆盖 client 里面已经设置好的重复字段;对于 client 和 default 都需要异步函数的情形还支持不了。
https://gist.github.com/troyeagle/b10774eff060cc6c6d1ed51ba8d842ec 可能是一种解决方法。总之用异步函数设定的值会打破原先 default 和 client 的加载顺序。求教在这种情形下应该怎么考虑设计
Checklist
npm test
passesAffected core subsystem(s)
Description of change
oss 的 ak/sk 可能配置的是加密的,启动的时候可能需要先调用 api 进行解密