Skip to content

Commit 2bd4a8d

Browse files
authored
[FIT] 修改组件启动优先级并添加文档 (#393)
* 修改工具仓库组件启动优先级并添加文档 * 修改文档 * 修改文档 * 修改插件顺序说明 * 修改插件顺序说明 * 修改插件启动顺序
1 parent 4e7c16b commit 2bd4a8d

File tree

3 files changed

+327
-1
lines changed

3 files changed

+327
-1
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# FEL插件启动顺序说明
2+
3+
## 概述
4+
5+
本文档记录了 FEL 插件的启动顺序。当应用以 JAR 包方式运行时,FIT 框架会按照 **Level**值从小到大的顺序加载这些插件。
6+
7+
**build/plugins 插件统计**:
8+
9+
- **FEL 插件**: 9个(本文档详细说明)
10+
- **FIT 内置插件**: 20个(详见 `framework/fit/java/fit-builtin/plugins/FIT插件启动顺序说明.md`
11+
12+
**启动规则**:
13+
14+
- **category=SYSTEM (id=1) 的插件先于 USER (id=2) 插件加载**
15+
- **相同 category 内,level 数值越小,启动优先级越高**
16+
- **相同 category 和 level 的插件,加载顺序不确定**
17+
18+
**默认值**
19+
20+
- 未指定 category 时,默认为 **category=USER**
21+
- 未指定 level 时,默认为 **level=4**
22+
23+
---
24+
25+
## 启动流程图
26+
27+
**启动顺序(两级排序:category → level)**
28+
29+
```
30+
插件启动顺序(29个插件)
31+
32+
├─ 阶段1: SYSTEM 插件启动
33+
│ │
34+
│ ├─ Level 4 (21个)
35+
│ │ ├─ FIT 内置插件 (20个,详见FIT文档)
36+
│ │ └─ fel-tool-repository-simple
37+
│ │
38+
│ ├─ Level 5 (5个)
39+
│ │ ├─ fel-tool-discoverer
40+
│ │ ├─ fel-tool-executor
41+
│ │ ├─ fel-tool-factory-repository
42+
│ │ ├─ fel-tool-mcp-client
43+
│ │ └─ fel-tool-mcp-server
44+
│ │
45+
│ └─ Level 7 (1个)
46+
│ └─ fel-model-openai-plugin
47+
48+
└─ 阶段2: USER 插件启动
49+
50+
├─ Level 1 (1个)
51+
│ └─ fel-tokenizer-hanlp-plugin
52+
53+
└─ Level 4 (1个)
54+
└─ fel-langchain-runnable
55+
```
56+
57+
---
58+
59+
## 插件依赖关系
60+
61+
### 启动时依赖
62+
63+
| 依赖方插件 | 被依赖插件 | 依赖说明 |
64+
|---------------------------------|----------------------------------------|--------------------------------------------|
65+
| `fel-tool-discoverer` (Level 5) | `fel-tool-repository-simple` (Level 4) |`onPluginStarted()` 回调时调用 `addTool()` 方法 |
66+
67+
---
68+
69+
## FEL插件清单
70+
71+
### 阶段1: SYSTEM 插件
72+
73+
#### category=SYSTEM, level=4 (1个)
74+
75+
| 插件名称 | 说明 |
76+
|------------------------------|------------|
77+
| `fel-tool-repository-simple` | 工具仓库(简单实现) |
78+
79+
**FIT 内置插件**: Level 4 还包含 20 个 FIT 框架内置插件(category=SYSTEM),提供 HTTP 服务、序列化、验证、服务发现等核心功能。详见
80+
`framework/fit/java/fit-builtin/plugins/FIT插件启动顺序说明.md`
81+
82+
---
83+
84+
#### category=SYSTEM, level=5 (5个)
85+
86+
| 插件名称 | 说明 |
87+
|-------------------------------|---------|
88+
| `fel-tool-discoverer` | 工具发现器 |
89+
| `fel-tool-executor` | 工具执行器 |
90+
| `fel-tool-factory-repository` | 工具工厂仓库 |
91+
| `fel-tool-mcp-client` | MCP 客户端 |
92+
| `fel-tool-mcp-server` | MCP 服务端 |
93+
94+
---
95+
96+
#### category=SYSTEM, level=7 (1个)
97+
98+
| 插件名称 | 说明 |
99+
|---------------------------|-------------|
100+
| `fel-model-openai-plugin` | OpenAI 模型集成 |
101+
102+
---
103+
104+
### 阶段2: USER 插件
105+
106+
#### category=USER, level=1 (1个)
107+
108+
| 插件名称 | 说明 |
109+
|------------------------------|-----------|
110+
| `fel-tokenizer-hanlp-plugin` | HanLP 分词器 |
111+
112+
---
113+
114+
#### category=USER, level=4 (1个)
115+
116+
| 插件名称 | 说明 |
117+
|--------------------------|-----------------|
118+
| `fel-langchain-runnable` | LangChain 运行时支持 |

framework/fel/java/plugins/tool-repository-simple/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<version>${fit.version}</version>
4545
<configuration>
4646
<category>system</category>
47-
<level>5</level>
47+
<level>4</level>
4848
</configuration>
4949
<executions>
5050
<execution>
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
# FIT插件启动顺序说明
2+
3+
## 概述
4+
5+
本文档记录了 FIT Framework 内置插件的启动顺序。FIT 内置插件共定义了 **22 个**,其中:
6+
7+
- **20 个**会自动输出到 `build/plugins/` 目录
8+
- **2 个**不在 `build/plugins/` 目录中(需单独配置)
9+
10+
所有 FIT 插件均配置为 **category=SYSTEM, level=4**
11+
12+
---
13+
14+
## 启动顺序说明
15+
16+
### 整体启动阶段
17+
18+
```
19+
FIT 框架插件启动顺序
20+
21+
├─ 阶段1: SYSTEM 插件启动
22+
│ │
23+
│ └─ Level 4 (20个自动输出 + 2个可选)
24+
│ └─ FIT 内置插件
25+
26+
└─ 阶段2: USER 插件启动
27+
```
28+
29+
**FIT 内置插件均配置为 SYSTEM Level 4,为应用层插件提供基础服务。**
30+
31+
### 启动规则
32+
33+
- **category=SYSTEM (id=1) 的插件先于 USER (id=2) 插件加载**
34+
- **相同 category 内,level 数值越小,启动优先级越高**
35+
- **相同 category 和 level 的插件,加载顺序不确定**
36+
37+
**默认值**
38+
- 未指定 category 时,默认为 **category=USER**
39+
- 未指定 level 时,默认为 **level=4**
40+
41+
---
42+
43+
## 自动添加的FIT插件
44+
45+
这 20 个插件会在构建时自动复制到 `build/plugins/` 目录(插件均配置为 category=SYSTEM, level=4):
46+
47+
| 序号 | 插件名称 | 说明 |
48+
|----|---------------------------------------|-------------------|
49+
| 1 | `fit-actuator` | 监控端点 |
50+
| 2 | `fit-client-http` | HTTP 客户端 |
51+
| 3 | `fit-dynamic-plugin-directory` | 动态插件目录 |
52+
| 4 | `fit-heartbeat-client` | 心跳客户端 |
53+
| 5 | `fit-http-client-okhttp` | OkHttp 客户端 |
54+
| 6 | `fit-http-handler-registry` | HTTP 处理器注册 |
55+
| 7 | `fit-http-openapi3-swagger` | OpenAPI 3/Swagger |
56+
| 8 | `fit-http-server-netty` | Netty HTTP 服务器 |
57+
| 9 | `fit-logger` | 日志组件 |
58+
| 10 | `fit-message-serializer-cbor` | CBOR 序列化 |
59+
| 11 | `fit-message-serializer-json-jackson` | Jackson JSON 序列化 |
60+
| 12 | `fit-security-simple` | 简单安全 |
61+
| 13 | `fit-server-http` | HTTP 服务器 |
62+
| 14 | `fit-service-coordination-locator` | 服务定位 |
63+
| 15 | `fit-service-coordination-simple` | 简单服务协调 |
64+
| 16 | `fit-service-discovery` | 服务发现 |
65+
| 17 | `fit-service-registry` | 服务注册 |
66+
| 18 | `fit-validation-hibernate-jakarta` | Jakarta 验证 |
67+
| 19 | `fit-validation-hibernate-javax` | Javax 验证 |
68+
| 20 | `fit-value-fastjson` | Fastjson 支持 |
69+
70+
**注意**: 表格中的序号仅用于标识,不代表实际加载顺序。相同 category 和 level 的插件之间的加载顺序是不确定的。
71+
72+
---
73+
74+
## 需要手动添加的插件
75+
76+
以下插件在源码中定义,但**不会自动输出**`build/plugins/` 目录,需要手动添加(插件均配置为 category=SYSTEM, level=4):
77+
78+
### 1. fit-dynamic-plugin-mvn
79+
80+
| 属性 ||
81+
|----------|-----------------------------------------------------------------|
82+
| **插件名** | fit-dynamic-plugin-mvn |
83+
| **源码路径** | `framework/fit/java/fit-builtin/plugins/fit-dynamic-plugin-mvn` |
84+
| **说明** | Maven 动态插件加载器 |
85+
| **用途** | 从 Maven 仓库动态加载插件 |
86+
87+
### 2. fit-service-coordination-nacos
88+
89+
| 属性 ||
90+
|----------|-------------------------------------------------------------------------|
91+
| **插件名** | fit-service-coordination-nacos |
92+
| **源码路径** | `framework/fit/java/fit-builtin/plugins/fit-service-coordination-nacos` |
93+
| **说明** | Nacos 服务协调实现 |
94+
| **用途** | 使用 Nacos 进行服务注册和发现 |
95+
96+
---
97+
98+
## 插件功能分类
99+
100+
虽然所有 FIT 插件都在 Level 4 启动,但它们提供不同类别的功能:
101+
102+
### HTTP 服务相关(7个)
103+
104+
- `fit-client-http` - HTTP 客户端接口
105+
- `fit-http-client-okhttp` - OkHttp 客户端实现
106+
- `fit-http-handler-registry` - HTTP 处理器注册
107+
- `fit-http-openapi3-swagger` - OpenAPI 3 和 Swagger UI
108+
- `fit-http-server-netty` - Netty HTTP 服务器实现
109+
- `fit-server-http` - HTTP 服务器接口
110+
- `fit-heartbeat-client` - 心跳客户端
111+
112+
### 序列化相关(3个)
113+
114+
- `fit-message-serializer-cbor` - CBOR 格式序列化
115+
- `fit-message-serializer-json-jackson` - JSON 格式序列化(Jackson)
116+
- `fit-value-fastjson` - Fastjson 值支持
117+
118+
### 服务协调相关(5个,其中1个可选)
119+
120+
- `fit-service-coordination-locator` - 服务定位器
121+
- `fit-service-coordination-simple` - 简单服务协调实现(默认)
122+
- `fit-service-coordination-nacos` - Nacos 服务协调实现(可选,不在 build/plugins)
123+
- `fit-service-discovery` - 服务发现
124+
- `fit-service-registry` - 服务注册
125+
126+
### 验证和安全(3个)
127+
128+
- `fit-validation-hibernate-jakarta` - Jakarta Bean Validation
129+
- `fit-validation-hibernate-javax` - Javax Bean Validation
130+
- `fit-security-simple` - 简单安全实现
131+
132+
### 动态插件加载(2个,其中1个可选)
133+
134+
- `fit-dynamic-plugin-directory` - 从目录加载插件(默认)
135+
- `fit-dynamic-plugin-mvn` - 从 Maven 仓库加载插件(可选,不在 build/plugins)
136+
137+
### 其他(2个)
138+
139+
- `fit-actuator` - 应用监控端点
140+
- `fit-logger` - 日志组件
141+
142+
---
143+
144+
## 源代码位置
145+
146+
所有 FIT 内置插件的源码位于:`framework/fit/java/fit-builtin/plugins/`
147+
148+
```
149+
framework/fit/java/fit-builtin/plugins/
150+
├── pom.xml # 父 POM,统一配置 level=4
151+
152+
├── fit-actuator/
153+
├── fit-client-http/
154+
├── fit-dynamic-plugin-directory/
155+
├── fit-dynamic-plugin-mvn/ # 不会自动输出到build/plugins
156+
├── fit-heartbeat-client/
157+
├── fit-http-client-okhttp/
158+
├── fit-http-handler-registry/
159+
├── fit-http-openapi3-swagger/
160+
├── fit-http-server-netty/
161+
├── fit-logger/
162+
├── fit-message-serializer-cbor/
163+
├── fit-message-serializer-json-jackson/
164+
├── fit-security-simple/
165+
├── fit-server-http/
166+
├── fit-service-coordination-locator/
167+
├── fit-service-coordination-simple/
168+
├── fit-service-coordination-nacos/ # 不会自动输出到build/plugins
169+
├── fit-service-discovery/
170+
├── fit-service-registry/
171+
├── fit-validation-hibernate-jakarta/
172+
├── fit-validation-hibernate-javax/
173+
└── fit-value-fastjson/
174+
```
175+
176+
### 父 POM 配置
177+
178+
所有 FIT 内置插件继承自 `fit-builtin/plugins/pom.xml`,该文件统一配置了:
179+
180+
```xml
181+
182+
<build>
183+
<plugins>
184+
<plugin>
185+
<groupId>org.fitframework</groupId>
186+
<artifactId>fit-build-maven-plugin</artifactId>
187+
<configuration>
188+
<category>system</category>
189+
<level>4</level> <!-- 所有子插件继承此配置 -->
190+
</configuration>
191+
<executions>
192+
<execution>
193+
<id>build-plugin</id>
194+
<goals>
195+
<goal>build-plugin</goal>
196+
</goals>
197+
</execution>
198+
<execution>
199+
<id>package-plugin</id>
200+
<goals>
201+
<goal>package-plugin</goal>
202+
</goals>
203+
</execution>
204+
</executions>
205+
</plugin>
206+
</plugins>
207+
</build>
208+
```

0 commit comments

Comments
 (0)