Skip to content
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

feat: implement RuntimeConfig #144

Merged
merged 6 commits into from
Aug 24, 2023
Merged

feat: implement RuntimeConfig #144

merged 6 commits into from
Aug 24, 2023

Conversation

popomore
Copy link
Member

@popomore popomore commented Aug 23, 2023

RuntimeConfig can be injected in tegg and standalone

It contains

  • baseDir
  • env
  • name
Checklist
  • npm test passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)
Description of change

Get RuntimeConfig through RuntimeConfigUtil

It contains

- baseDir
- env
- name
@popomore popomore changed the title feat: impliment RuntimeConfigUtil feat: implement RuntimeConfigUtil Aug 23, 2023
baseDir: string;
}

export class RuntimeConfigUtil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里应该只是一个定义

class RuntimeConfig {
  name: string;
  env: string;
  baseDir: string;
}

在具体的 runtime 中把这个类构造出来。

这样就能解决多个实例的问题了。

Copy link
Member Author

@popomore popomore Aug 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

所以这里还是类型注入的模式?用法就是

import type { RuntimeConfig } from '@alipay/tegg-common-util';

@SingletonProto()
class Example {
  @Inject()
  runtimeConfig: RuntimeConfig;

}

Copy link
Contributor

@killagu killagu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -20,6 +21,11 @@ export default class App {
}

configWillLoad() {
RuntimeConfigUtil.setRuntimeConfig({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里也改成一下就好了

@popomore popomore changed the title feat: implement RuntimeConfigUtil feat: implement RuntimeConfig Aug 24, 2023
@codecov
Copy link

codecov bot commented Aug 24, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (6638967) 93.76% compared to head (7ee310d) 93.77%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #144   +/-   ##
=======================================
  Coverage   93.76%   93.77%           
=======================================
  Files         227      227           
  Lines        4731     4738    +7     
  Branches      509      509           
=======================================
+ Hits         4436     4443    +7     
  Misses        295      295           
Files Changed Coverage Δ
core/tegg/index.ts 100.00% <ø> (ø)
standalone/standalone/src/StandaloneLoadUnit.ts 93.47% <ø> (ø)
core/common-util/index.ts 100.00% <100.00%> (ø)
plugin/tegg/app/extend/application.ts 93.02% <100.00%> (+0.71%) ⬆️
standalone/standalone/src/Runner.ts 91.46% <100.00%> (+0.21%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@killagu
Copy link
Contributor

killagu commented Aug 24, 2023

LGTM

@fengmk2 fengmk2 added this pull request to the merge queue Aug 24, 2023
Merged via the queue into master with commit 0862655 Aug 24, 2023
17 checks passed
@fengmk2 fengmk2 deleted the RuntimeConfigUtil branch August 24, 2023 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants