sofastack / sofa-boot

SOFABoot is a framework that enhances Spring Boot and fully compatible with it, provides readiness check, class isolation, etc.
https://www.sofastack.tech/sofa-boot/docs/Home
Apache License 2.0
4.93k stars 1.26k forks source link

Refactor project code and organization in 3.2.0 #452

Closed QilongZhang closed 4 years ago

QilongZhang commented 5 years ago

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

工程模块改造

.
└── 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 工程,这样做的原因有两点:

注意点

sofastack-bot[bot] commented 5 years ago

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

ScienJus commented 5 years ago

将 SOFARPC Starter 挪至 SOFABoot 工程

totally agree!

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

chpengzh commented 5 years ago

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

chpengzh commented 5 years ago

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

ScienJus commented 5 years ago

我看这里拆分了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 commented 5 years ago

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

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

chpengzh commented 5 years ago

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

QilongZhang commented 5 years ago

将 SOFARPC Starter 挪至 SOFABoot 工程

totally agree!

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

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

chpengzh commented 5 years ago

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

wangyjx commented 4 years ago

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