-
Notifications
You must be signed in to change notification settings - Fork 93
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
refactor API #5
refactor API #5
Conversation
@popomore, thanks for your PR! By analyzing the annotation information on this pull request, we identified @gxcsoccer and @fengmk2 to be potential reviewers |
deps #4 |
Load order has changed from `app > framework > plugin > egg` to `app > framework(contain egg) > plugin` Remove options.eggPath, egg is one of the framework. Remove options.customEgg, every framework should specify `Symbol.for('egg#eggPath')`
changes - loadApplication > loadApplicationExtend - loadContext > loadContextExtend - loadRequest > loadRequestExtend - loadResponse > loadResponseExtend - loadHelper > loadHelperExtend
eggjs/egg#19 (comment) 把 loader 改完后再转成 core |
loadUnit is a directory that can be loaded by EggLoader
发现在 loader service 的时候设置 call 为 false,但是 classLoader 里还会 call
|
this.serverEnv = this.getServerEnv(); | ||
debug('Loaded serverEnv %j', this.serverEnv); | ||
|
||
this.appInfo = { |
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.
是否每个 config 都需要全新的 appinfo?现在这样如果改了会影响其他的。
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.
不需要吧,如果需要自定义,覆盖对应的方法即可。
move proxy/service to mixin
原来还支持框架的 lib/plugins 目录加载插件 |
- framework's directory will change from lib/core to framework base - dont' lookup plugin from lib/plugins directory
/** | ||
* Get all framework directories. | ||
* | ||
* You can extend Application of egg, the extrypoint is options.app, |
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.
entrypoint
代码清晰多了。 |
Review status: 0 of 66 files reviewed at latest revision, 7 unresolved discussions. lib/egg_loader.js, line 121 [r5] (raw file):
|
9804cfb
to
306a71d
Compare
Review status: 0 of 68 files reviewed at latest revision, 7 unresolved discussions. lib/context_loader.js, line 26 [r5] (raw file):
|
reviewable 不会用 |
改好了 |
lib/context_loader.js, line 26 [r5] (raw file):
|
Reviewed 1 of 3 files at r1, 11 of 21 files at r2, 21 of 30 files at r3, 8 of 11 files at r4, 26 of 27 files at r5, 2 of 2 files at r6, 13 of 13 files at r7. lib/egg_loader.js, line 121 [r5] (raw file):
|
我知道为啥了 @fengmk2 也是 review 人 |
serverEnv = process.env.EGG_SERVER_ENV; | ||
} | ||
|
||
if (!serverEnv) { |
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.
根据 NODE_ENV 做的逻辑判断最好是能够有个说明,不然感觉容易踩坑
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.
这个放到使用文档说明吧,api 文档就不写了
and fix review
+1 |
│ ├── service (optional) | ||
│ ├── middleware (optional) | ||
│ │ └── response_time.js | ||
│ └── view (optional) |
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.
views
```bash egg start timeline: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ [289ms] - #0 Process Start ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ [510ms] - #1 Application Start ▇ [2ms] - #2 Load Plugin ▇ [1ms] - #3 Load Config ▇ [0ms] - #4 Require(0) ~/eggjs/egg-core/test/fixtures/egg/config/config.default.js ▇ [0ms] - #5 Require(1) ~/eggjs/egg-core/test/fixtures/egg/config/config.unittest.js ▇ [0ms] - #6 Load extend/application.js ▇ [0ms] - #7 Require(2) ~/eggjs/egg-core/test/fixtures/egg/app/extend/application.js ▇ [1ms] - #8 Load extend/context.js ▇ [0ms] - #9 Load extend/request.js ▇ [0ms] - #10 Load extend/response.js ▇ [1ms] - #11 Load app.js ▇ [0ms] - #12 Require(3) ~/eggjs/egg-core/test/fixtures/egg/node_modules/session/app.js ▇ [0ms] - #13 Require(4) app.js ▇▇▇▇▇▇ [101ms] - #14 readyCallback in a ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ [501ms] - #15 readyCallback in b ▇ [4ms] - #16 Load Middleware ▇ [4ms] - #17 Load "middlewares" to Application ▇ [2ms] - #18 Load Service ▇ [2ms] - #19 Load "service" to Context ▇ [0ms] - #20 Load Controller ▇ [0ms] - #21 Load "controller" to Application ▇ [0ms] - #22 Load Router ```
```bash egg start timeline: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ [289ms] - #0 Process Start ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ [510ms] - #1 Application Start ▇ [2ms] - #2 Load Plugin ▇ [1ms] - #3 Load Config ▇ [0ms] - #4 Require(0) ~/eggjs/egg-core/test/fixtures/egg/config/config.default.js ▇ [0ms] - #5 Require(1) ~/eggjs/egg-core/test/fixtures/egg/config/config.unittest.js ▇ [0ms] - #6 Load extend/application.js ▇ [0ms] - #7 Require(2) ~/eggjs/egg-core/test/fixtures/egg/app/extend/application.js ▇ [1ms] - #8 Load extend/context.js ▇ [0ms] - #9 Load extend/request.js ▇ [0ms] - #10 Load extend/response.js ▇ [1ms] - #11 Load app.js ▇ [0ms] - #12 Require(3) ~/eggjs/egg-core/test/fixtures/egg/node_modules/session/app.js ▇ [0ms] - #13 Require(4) app.js ▇▇▇▇▇▇ [101ms] - #14 readyCallback in a ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ [501ms] - #15 readyCallback in b ▇ [4ms] - #16 Load Middleware ▇ [4ms] - #17 Load "middlewares" to Application ▇ [2ms] - #18 Load Service ▇ [2ms] - #19 Load "service" to Context ▇ [0ms] - #20 Load Controller ▇ [0ms] - #21 Load "controller" to Application ▇ [0ms] - #22 Load Router ```
[skip ci] ## [5.3.0](v5.2.0...v5.3.0) (2023-01-13) ### Features * support show app.timing in timline string ([#260](#260)) ([5b7af12](5b7af12)), closes [#0](https://github.com/eggjs/egg-core/issues/0) [#1](#1) [#2](#2) [#3](#3) [#4](#4) [#5](#5) [#6](#6) [#7](#7) [#8](#8) [#9](#9) [#10](#10) [#11](#11) [#12](#12) [#13](#13) [#14](#14) [#15](#15) [#16](#16) [#17](#17) [#18](#18) [#19](#19) [#20](#20) [#21](#21) [#22](#22)
做到灵活性,扩展性强。
API
loader 只提供原子粒度的 API,由框架来自行组织
Env
Low Level API
High Level API
和插件的关系
插件需要用到 loader 功能需要增加一个 loader 插件,比如 db 的功能
新增 egg-loader-db 插件
db 插件直接依赖 egg-loader-db 插件
load unit
每个加载单元的目录结构都是类似的,框架、插件、应用的路径都是称为 loadUnit。
LoaderOptions
Action
eggjs/egg#19
This change is