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

Refactor project code and organization in 3.2.0 #452

Closed
QilongZhang opened this issue Jul 10, 2019 · 10 comments

Comments

@QilongZhang
Copy link
Contributor

commented Jul 10, 2019

在保证兼容性的情况下,我们计划将在 SOFABoot 3.2.0 重构工程代码和组织结构,整体改造目标有两个:

  • 尽可能使代码风格偏向 Spring boot
  • 参考 Spring,将 SOFARPC Starter 和 SOFATracer Starter 挪至 SOFABoot 工程。

工程模块改造

.
└── sofa-boot-build
    ├── sofa-boot-project
    │   ├── sofa-boot
    │   ├── sofa-boot-actuator
    │   ├── sofa-boot-actuator-autoconfigure
    │   ├── sofa-boot-autoconfigure
    │   ├── sofa-boot-core
    │   │   ├── runtime-sofa-boot
    │   │   ├── isle-sofa-boot
    │   │   ├── healthcheck-sofa-boot
    │   │   ├── rpc-sofa-boot
    │   │   ├── tracer-sofa-boot
    │   │   └── test-sofa-boot
    │   │   
    │   ├── sofa-boot-parent
    │   ├── sofaboot-dependencies
    │   ├── sofa-boot-plugin
    │   │   ├── runtime-sofa-boot-plugin
    │   │   ├── rpc-sofa-boot-plugin
    │   │   └── tracer-sofa-boot-plugin
    │   │ 
    │   ├── sofa-boot-starters
    │   │   ├── runtime-sofa-boot-starter
    │   │   ├── isle-sofa-boot-starter
    │   │   ├── healthcheck-sofa-boot-starter
    │   │   ├── infra-sofa-boot-starter
    │   │   ├── test-sofa-boot-starter
    │   │   ├── rpc-sofa-boot-starter
    │   │   └── tracer-sofa-boot-starter
    │   │
    │   └── sofa-boot-tools
    │       └── sofa-boot-gradle-plugin
    │
    └── sofaboot-samples
        ├── sofaboot-sample
        ├── ... 
        └── sofaboot-sample-with-rpc

相较于之前的模块组织方式,我们参考了 Spring Boot 官方文档建议:

除了遵循上述开发建议之外,本次改造将 SOFARPC Starter 以及 SOFATracer Starter 相关代码挪至 SOFABoot 工程,这样做的原因有两点:

  • 避免工程分散各处,所有 Starter 走一个发布流程
  • 核心包和Starter分离,比如 tracer-core 和 tracer starter, 避免因为 starter 升级导致 core 包升级

注意点

  • SOFARPC starter 同步分支为 6.0.4-SNAPSHOT (确保所有 commit 均已被 cherry-pick)
  • SOFATracer starter 同步分支为 3.0.5
@sofastack-bot

This comment has been minimized.

Copy link

commented Jul 10, 2019

Hi @QilongZhang, we detect non-English characters in the issue. This comment is an auto translation by @sofastack-robot to help other users to understand this issue.

We encourage you to describe your issue in English which is more friendly to other users.

In the case of compatibility, we plan to refactor the engineering code and organizational structure in SOFABoot 3.2.0. There are two overall transformation goals: Try to make the code style biased towards Spring boot. Learn Spring, move SOFARPC Starter and SOFATracer Starter to SOFABoot project. ####工程模块改造```txt. └──bike-boot-build ├──bow-boot-project │ ├──bow-boot │ ├──bow-boot-actuator │ ├──bike- Boot-actuator-autoconfigure │ ├──bow-boot-autoconfigure │ ├──bow-boot-core │ │ ├── runtime-sofa-boot │ │ ├── isle-sofa-boot │ │ ├── healthcheck- Sofa-boot │ │ ├── rpc-sofa-boot │ │ ├── tracer-sofa-boot │ │ └── test-sofa-boot │ │ │ ├── sofa-boot-parent │ ├── sofaboot- Dependencies │ ├── sofa-boot-plugin │ │ ├── runtime-sofa-boot-plugin │ │ ├── rpc-sofa-boot-plugin │ │ └── tracer-sofa-boot-plugin │ │ │ ├ ——, sofa-boot-starters │ │ ├── runtime-sofa-boot-starter │ │ ├── isle-sofa-boot-starter │ │ ├── healthcheck-sofa-boot-starter │ │ ├── infra- Sofa-boot-starter │ │ ├── test-sofa-boot-starter │ │ ├── rpc-sofa-boot-st Arter │ │ └── tracer-sofa-boot-starter │ │ │ └── sofa-boot-tools │ └──bow-boot-gradle-plugin │ └──bowboot-samples ├──bowboot-sample ├─ ─ └ sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa sofa Spring.io/spring-boot/docs/current/reference/html/boot-features-developing-auto-configuration.html) [Building On Spring Boot] (https://github.com/spring-projects/spring-boot /wiki/Building-On-Spring-Boot) In addition to following the above development recommendations, this transformation moved the SOFARPC Starter and SOFATracer Starter related code to the SOFABoot project for two reasons: Avoiding the project being scattered everywhere, all Starter takes a release process core package and Starter separation, such as tracer-core and tracer starter, to avoid core package upgrade due to starter upgrade

@QilongZhang QilongZhang added this to the 3.2.0 milestone Jul 10, 2019

@ScienJus

This comment has been minimized.

Copy link
Member

commented Jul 10, 2019

将 SOFARPC Starter 挪至 SOFABoot 工程

totally agree!

PS:为什么 sofa-boot-actuator 在最顶层以及有一个单独的 autoconfigure?

@chpengzh

This comment has been minimized.

Copy link
Member

commented Jul 10, 2019

springboot的starter每个模块是同一份代码不同依赖;我看这里拆分了core,在starter那里是只引用自己core实现,还是说全部都会引用啊。

@chpengzh

This comment has been minimized.

Copy link
Member

commented Jul 10, 2019

还有一个问题,如果我没有理解错,目前healthcheck应该拓展了actuator的功能,可不可以只保留一个模块呢

@ScienJus

This comment has been minimized.

Copy link
Member

commented Jul 10, 2019

我看这里拆分了core,在starter那里是只引用自己core实现,还是说全部都会引用啊。

@chpengzh 一般我比较熟悉的做法是:

  1. 把所有和 autoconfig 加载逻辑无关的代码都放在 core 里
  2. 把多个 core 的 spring boot 加载逻辑可以都写在同一个 autoconfig 里,用 conditional 条件化加载
  3. starter 只是 pom 集合,一般一个项目的 starter 只负责将 autoconfig(可以是公共的)以及 core(对应的)整体引入到项目中

和这个场景比较像的应用像是 1.x 版本的 spring-cloud-netflix,对应关系大概是:

  1. sofa-boot 中的 core 对应 netflix 原生的组件,比如 hystrix/ribbon
  2. sofa-boot 中的 autoconfig 可以对应 spring-cloud-netflix 中的 spring-cloud-netflix-core,实现了所有模块的 autoconfig
  3. sofa-boot 中的 starter 可以对应 spring-cloud-netflix 中的每一个 spring-cloud-starter-netflix-*,只负责整合依赖
@chpengzh

This comment has been minimized.

Copy link
Member

commented Jul 10, 2019

@ScienJus 嗯,大概就是这个意思 xxx-boot 本来就应该是一个条件加载引用的垃圾堆,拆分了之后如果有多个模块都要用到同一个bean,写的时候就要怀疑人生了。

这里可能表述的有点不清楚,随着各个模块(rpc, test ...)的实现发展,boot这边的代码是不可预估的,说不定明天可能就会有两个模块依赖到一个DataSource或者一个CuratorFramework。这种情况下拆分boot装配代码可能不太合适,要么两边用不同beanName,要么两边各自condition+order,不管哪一种都没有把boot代码合并到一个模块下好。

@chpengzh

This comment has been minimized.

Copy link
Member

commented Jul 10, 2019

还有如果有个starter-all的话应该会很受欢迎

@QilongZhang

This comment has been minimized.

Copy link
Contributor Author

commented Jul 11, 2019

将 SOFARPC Starter 挪至 SOFABoot 工程

totally agree!

PS:为什么 sofa-boot-actuator 在最顶层以及有一个单独的 autoconfigure?

感谢 @ScienJus 回复。
SOFABoot 提供了若干 endpoint,放在 sofa-boot-actuator 中,这两个模块参考了 Spring Boot 的设计. PR 已提,欢迎指正。

@chpengzh

This comment has been minimized.

Copy link
Member

commented Jul 11, 2019

soga, 原来autoconfig部分还是统一放在一起的,我理解错了

@wangyjx

This comment has been minimized.

Copy link

commented Aug 7, 2019

3.2有没有预计的发布时间?

@caojie09 caojie09 closed this Sep 3, 2019

@caojie09 caojie09 changed the title Project Code and organization would be refactored in 3.2.0 Refactor project code and organization in 3.2.0 Sep 3, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.