Skip to content

Commit b96fe46

Browse files
authored
Add nacos registry plugin (#178)
* [fit] 增加fit-server-coordination-nacos内置插件 * [fit] 增加Registry port、IP信息的动态获取 * [fit] 修改nacos默认配置,最简单化 * [fit] 修改nacos notify函数死循环bug * [fit] 增加nacos的使用example以及一些类的注释 * [fit] 修改example8中的nacos地址为本地地址 * [fit] 修改example8中的nacos地址为本地地址 * [fit] 修改文件的格式问题以及增加必要的注释 * [fit] 毫秒时间类型设置为long * [fit] 修改格式错误以及方法抽取 * [fit] 修改注释错误以及方法抽取 * [fit] 统一修改和registry相关的fitable-id和genericable-id * [fit] 统一修改和registry相关的fitable-id和genericable-id; 增加Notify接口; 修改注释为英文; 支持用户对nacos配置 * [fit] 增加缺失的 this. * [fit] 为 NacosConfig 增加详细注释; 修改heartBeat错误拼写; 修改部分未修改的fitableId * [fit] 修改某个fitableId * [fit] 统一内存版注册中心和nacos注册中心的配置方式 * [fit] 增加注册中心连接模式,默认DIRECT模式,还可设置为PROXY模式 * [fit] 删除不必要的配置信息 * [fit] matata.registry.nacos配置改从插件中读取 * [fit] 修改格式错误 * [fit] 修改代码格式错误 * [fit] 修改代码格式错误,增加this.
1 parent 3da5e80 commit b96fe46

File tree

32 files changed

+1688
-356
lines changed

32 files changed

+1688
-356
lines changed
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>org.fitframework.example</groupId>
7+
<artifactId>nacos-assistant-for-complicated</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
10+
<properties>
11+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
12+
<java.version>17</java.version>
13+
14+
<!-- FIT version -->
15+
<fit.version>3.6.0-SNAPSHOT</fit.version>
16+
17+
<!-- Maven plugin versions -->
18+
<maven.compiler.version>3.14.0</maven.compiler.version>
19+
</properties>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>org.fitframework.example</groupId>
24+
<artifactId>nacos-weather-for-complicated</artifactId>
25+
<version>1.0-SNAPSHOT</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.fitframework</groupId>
29+
<artifactId>fit-starter</artifactId>
30+
<version>${fit.version}</version>
31+
</dependency>
32+
33+
<!-- FIT plugins -->
34+
<dependency>
35+
<groupId>org.fitframework</groupId>
36+
<artifactId>fit-plugins-starter-web</artifactId>
37+
<version>${fit.version}</version>
38+
</dependency>
39+
40+
<!-- 不在默认插件集合中的插件列表 -->
41+
<dependency>
42+
<groupId>org.fitframework.plugin</groupId>
43+
<artifactId>fit-client-http</artifactId>
44+
<version>${fit.version}</version>
45+
<scope>runtime</scope>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.fitframework.plugin</groupId>
49+
<artifactId>fit-http-client-okhttp</artifactId>
50+
<version>${fit.version}</version>
51+
<scope>runtime</scope>
52+
</dependency>
53+
<dependency>
54+
<groupId>org.fitframework.plugin</groupId>
55+
<artifactId>fit-heartbeat-client</artifactId>
56+
<version>${fit.version}</version>
57+
<scope>runtime</scope>
58+
</dependency>
59+
<dependency>
60+
<groupId>org.fitframework.plugin</groupId>
61+
<artifactId>fit-service-registry</artifactId>
62+
<version>${fit.version}</version>
63+
<scope>runtime</scope>
64+
</dependency>
65+
<dependency>
66+
<groupId>org.fitframework.plugin</groupId>
67+
<artifactId>fit-service-discovery</artifactId>
68+
<version>${fit.version}</version>
69+
<scope>runtime</scope>
70+
</dependency>
71+
<dependency>
72+
<groupId>org.fitframework.plugin</groupId>
73+
<artifactId>fit-service-coordination-locator</artifactId>
74+
<version>${fit.version}</version>
75+
<scope>runtime</scope>
76+
</dependency>
77+
<!-- 注册中心的内nacos版实现 -->
78+
<dependency>
79+
<groupId>org.fitframework.plugin</groupId>
80+
<artifactId>fit-service-coordination-nacos</artifactId>
81+
<version>${fit.version}</version>
82+
<scope>runtime</scope>
83+
</dependency>
84+
</dependencies>
85+
86+
<build>
87+
<plugins>
88+
<plugin>
89+
<groupId>org.apache.maven.plugins</groupId>
90+
<artifactId>maven-compiler-plugin</artifactId>
91+
<version>${maven.compiler.version}</version>
92+
<configuration>
93+
<source>${java.version}</source>
94+
<target>${java.version}</target>
95+
<encoding>${project.build.sourceEncoding}</encoding>
96+
<compilerArgs>
97+
<arg>-parameters</arg>
98+
</compilerArgs>
99+
</configuration>
100+
</plugin>
101+
<plugin>
102+
<groupId>org.fitframework</groupId>
103+
<artifactId>fit-build-maven-plugin</artifactId>
104+
<version>${fit.version}</version>
105+
<executions>
106+
<execution>
107+
<id>package-app</id>
108+
<goals>
109+
<goal>package-app</goal>
110+
</goals>
111+
</execution>
112+
</executions>
113+
</plugin>
114+
</plugins>
115+
</build>
116+
</project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
3+
* This file is a part of the ModelEngine Project.
4+
* Licensed under the MIT License. See License.txt in the project root for license information.
5+
*--------------------------------------------------------------------------------------------*/
6+
7+
package modelengine.fit.example;
8+
9+
import modelengine.fitframework.annotation.Component;
10+
import modelengine.fitframework.annotation.ScanPackages;
11+
import modelengine.fitframework.runtime.FitStarter;
12+
13+
/**
14+
* 启动类。
15+
*
16+
* @author 董智豪
17+
* @since 2025-06-21
18+
*/
19+
@Component
20+
@ScanPackages("modelengine")
21+
public class AssistantStarter {
22+
public static void main(String[] args) {
23+
FitStarter.start(AssistantStarter.class, args);
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
3+
* This file is a part of the ModelEngine Project.
4+
* Licensed under the MIT License. See License.txt in the project root for license information.
5+
*--------------------------------------------------------------------------------------------*/
6+
7+
package modelengine.fit.example.controller;
8+
9+
import modelengine.fit.example.Weather;
10+
import modelengine.fit.http.annotation.GetMapping;
11+
import modelengine.fitframework.annotation.Component;
12+
import modelengine.fitframework.annotation.Fit;
13+
14+
/**
15+
* 表示助手的控制器。
16+
*
17+
* @author 董智豪
18+
* @since 2025-06-21
19+
*/
20+
@Component
21+
public class AssistantController {
22+
private final Weather weather;
23+
24+
public AssistantController(@Fit Weather weather) {
25+
this.weather = weather;
26+
}
27+
28+
/**
29+
* 获取天气信息。
30+
*
31+
* @return 表示天气信息的 {@link String}。
32+
*/
33+
@GetMapping(path = "/weather")
34+
public String getWeather() {
35+
return this.weather.get();
36+
}
37+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
application:
2+
name: 'assistant'
3+
4+
worker:
5+
id: 'assistant'
6+
host: '127.0.0.1'
7+
environment: 'local'
8+
environment-sequence: 'local'
9+
10+
matata:
11+
registry:
12+
mode: 'PROXY'
13+
host: '127.0.0.1'
14+
port: 8848
15+
environment: 'local'
16+
17+
server:
18+
http:
19+
port: 8080
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>org.fitframework.example</groupId>
7+
<artifactId>nacos-default-weather-for-complicated</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
10+
<properties>
11+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
12+
<java.version>17</java.version>
13+
14+
<!-- FIT version -->
15+
<fit.version>3.6.0-SNAPSHOT</fit.version>
16+
17+
<!-- Maven plugin versions -->
18+
<maven.compiler.version>3.14.0</maven.compiler.version>
19+
</properties>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>org.fitframework.example</groupId>
24+
<artifactId>nacos-weather-for-complicated</artifactId>
25+
<version>1.0-SNAPSHOT</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.fitframework</groupId>
29+
<artifactId>fit-starter</artifactId>
30+
<version>${fit.version}</version>
31+
</dependency>
32+
33+
<!-- FIT plugins -->
34+
<dependency>
35+
<groupId>org.fitframework</groupId>
36+
<artifactId>fit-plugins-starter-web</artifactId>
37+
<version>${fit.version}</version>
38+
</dependency>
39+
40+
<!-- 不在默认插件集合中的插件列表 -->
41+
<dependency>
42+
<groupId>org.fitframework.plugin</groupId>
43+
<artifactId>fit-client-http</artifactId>
44+
<version>${fit.version}</version>
45+
<scope>runtime</scope>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.fitframework.plugin</groupId>
49+
<artifactId>fit-http-client-okhttp</artifactId>
50+
<version>${fit.version}</version>
51+
<scope>runtime</scope>
52+
</dependency>
53+
<dependency>
54+
<groupId>org.fitframework.plugin</groupId>
55+
<artifactId>fit-heartbeat-client</artifactId>
56+
<version>${fit.version}</version>
57+
<scope>runtime</scope>
58+
</dependency>
59+
<dependency>
60+
<groupId>org.fitframework.plugin</groupId>
61+
<artifactId>fit-service-registry</artifactId>
62+
<version>${fit.version}</version>
63+
<scope>runtime</scope>
64+
</dependency>
65+
<dependency>
66+
<groupId>org.fitframework.plugin</groupId>
67+
<artifactId>fit-service-discovery</artifactId>
68+
<version>${fit.version}</version>
69+
<scope>runtime</scope>
70+
</dependency>
71+
<dependency>
72+
<groupId>org.fitframework.plugin</groupId>
73+
<artifactId>fit-service-coordination-locator</artifactId>
74+
<version>${fit.version}</version>
75+
<scope>runtime</scope>
76+
</dependency>
77+
<dependency>
78+
<groupId>org.fitframework.plugin</groupId>
79+
<artifactId>fit-service-coordination-nacos</artifactId>
80+
<version>${fit.version}</version>
81+
<scope>runtime</scope>
82+
</dependency>
83+
</dependencies>
84+
85+
<build>
86+
<plugins>
87+
<plugin>
88+
<groupId>org.apache.maven.plugins</groupId>
89+
<artifactId>maven-compiler-plugin</artifactId>
90+
<version>${maven.compiler.version}</version>
91+
<configuration>
92+
<source>${java.version}</source>
93+
<target>${java.version}</target>
94+
<encoding>${project.build.sourceEncoding}</encoding>
95+
<compilerArgs>
96+
<arg>-parameters</arg>
97+
</compilerArgs>
98+
</configuration>
99+
</plugin>
100+
<plugin>
101+
<groupId>org.fitframework</groupId>
102+
<artifactId>fit-build-maven-plugin</artifactId>
103+
<version>${fit.version}</version>
104+
<executions>
105+
<execution>
106+
<id>package-app</id>
107+
<goals>
108+
<goal>package-app</goal>
109+
</goals>
110+
</execution>
111+
</executions>
112+
</plugin>
113+
</plugins>
114+
</build>
115+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
3+
* This file is a part of the ModelEngine Project.
4+
* Licensed under the MIT License. See License.txt in the project root for license information.
5+
*--------------------------------------------------------------------------------------------*/
6+
7+
package modelengine.fit.example;
8+
9+
import modelengine.fitframework.annotation.Component;
10+
import modelengine.fitframework.annotation.Fitable;
11+
12+
/**
13+
* 表示 {@link Weather} 的默认实现。
14+
*
15+
* @author 董智豪
16+
* @since 2025-06-21
17+
*/
18+
@Component
19+
public class DefaultWeather implements Weather {
20+
@Override
21+
@Fitable(id = "default-weather")
22+
public String get() {
23+
return "Default weather application is working.";
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
3+
* This file is a part of the ModelEngine Project.
4+
* Licensed under the MIT License. See License.txt in the project root for license information.
5+
*--------------------------------------------------------------------------------------------*/
6+
7+
package modelengine.fit.example;
8+
9+
import modelengine.fitframework.annotation.Component;
10+
import modelengine.fitframework.annotation.ScanPackages;
11+
import modelengine.fitframework.runtime.FitStarter;
12+
13+
/**
14+
* 启动类。
15+
*
16+
* @author 董智豪
17+
* @since 2025-06-21
18+
*/
19+
@Component
20+
@ScanPackages("modelengine")
21+
public class DefaultWeatherStarter {
22+
public static void main(String[] args) {
23+
FitStarter.start(DefaultWeatherStarter.class, args);
24+
}
25+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
application:
2+
name: 'default-weather'
3+
4+
worker:
5+
id: 'default-weather'
6+
host: '127.0.0.1'
7+
environment: 'local'
8+
environment-sequence: 'local'
9+
10+
matata:
11+
registry:
12+
mode: 'PROXY'
13+
host: '127.0.0.1'
14+
port: 8848
15+
environment: 'local'
16+
17+
server:
18+
http:
19+
port: 8081

0 commit comments

Comments
 (0)