-
Notifications
You must be signed in to change notification settings - Fork 329
Add nacos registry plugin #178
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
Merged
CodeCasterX
merged 23 commits into
ModelEngine-Group:main
from
mikeaaaaaa:fit-enhancement-nacos
Aug 8, 2025
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
f016710
[fit] 增加fit-server-coordination-nacos内置插件
mikeaaaaaa 195ef7a
[fit] 增加Registry port、IP信息的动态获取
mikeaaaaaa d9905b5
[fit] 修改nacos默认配置,最简单化
mikeaaaaaa db30014
[fit] 修改nacos notify函数死循环bug
mikeaaaaaa bacf73e
[fit] 增加nacos的使用example以及一些类的注释
mikeaaaaaa 790c86c
[fit] 修改example8中的nacos地址为本地地址
mikeaaaaaa 4dbd28b
[fit] 修改example8中的nacos地址为本地地址
mikeaaaaaa b8a1e31
[fit] 修改文件的格式问题以及增加必要的注释
mikeaaaaaa 7301779
[fit] 毫秒时间类型设置为long
mikeaaaaaa db796e9
[fit] 修改格式错误以及方法抽取
mikeaaaaaa 1a94b63
[fit] 修改注释错误以及方法抽取
mikeaaaaaa b5b7f2a
[fit] 统一修改和registry相关的fitable-id和genericable-id
mikeaaaaaa 2da9b35
[fit] 统一修改和registry相关的fitable-id和genericable-id; 增加Notify接口; 修改注释为英文;…
mikeaaaaaa 0a6fd93
[fit] 增加缺失的 this.
mikeaaaaaa 3aeea47
[fit] 为 NacosConfig 增加详细注释; 修改heartBeat错误拼写; 修改部分未修改的fitableId
mikeaaaaaa 634ed23
[fit] 修改某个fitableId
mikeaaaaaa d37d787
[fit] 统一内存版注册中心和nacos注册中心的配置方式
mikeaaaaaa f63b580
[fit] 增加注册中心连接模式,默认DIRECT模式,还可设置为PROXY模式
mikeaaaaaa 34fc5c5
[fit] 删除不必要的配置信息
mikeaaaaaa 3e3c375
[fit] matata.registry.nacos配置改从插件中读取
mikeaaaaaa 1385ed9
[fit] 修改格式错误
mikeaaaaaa 45f8688
[fit] 修改代码格式错误
mikeaaaaaa c2eb997
[fit] 修改代码格式错误,增加this.
mikeaaaaaa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
116 changes: 116 additions & 0 deletions
116
examples/fit-example/08-nacos-complicated-apps/app-assistant/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <groupId>org.fitframework.example</groupId> | ||
| <artifactId>nacos-assistant-for-complicated</artifactId> | ||
| <version>1.0-SNAPSHOT</version> | ||
|
|
||
| <properties> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| <java.version>17</java.version> | ||
|
|
||
| <!-- FIT version --> | ||
| <fit.version>3.6.0-SNAPSHOT</fit.version> | ||
|
|
||
| <!-- Maven plugin versions --> | ||
| <maven.compiler.version>3.14.0</maven.compiler.version> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.fitframework.example</groupId> | ||
| <artifactId>nacos-weather-for-complicated</artifactId> | ||
| <version>1.0-SNAPSHOT</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.fitframework</groupId> | ||
| <artifactId>fit-starter</artifactId> | ||
| <version>${fit.version}</version> | ||
| </dependency> | ||
|
|
||
| <!-- FIT plugins --> | ||
| <dependency> | ||
| <groupId>org.fitframework</groupId> | ||
| <artifactId>fit-plugins-starter-web</artifactId> | ||
| <version>${fit.version}</version> | ||
| </dependency> | ||
|
|
||
| <!-- 不在默认插件集合中的插件列表 --> | ||
| <dependency> | ||
| <groupId>org.fitframework.plugin</groupId> | ||
| <artifactId>fit-client-http</artifactId> | ||
| <version>${fit.version}</version> | ||
| <scope>runtime</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.fitframework.plugin</groupId> | ||
| <artifactId>fit-http-client-okhttp</artifactId> | ||
| <version>${fit.version}</version> | ||
| <scope>runtime</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.fitframework.plugin</groupId> | ||
| <artifactId>fit-heartbeat-client</artifactId> | ||
| <version>${fit.version}</version> | ||
| <scope>runtime</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.fitframework.plugin</groupId> | ||
| <artifactId>fit-service-registry</artifactId> | ||
| <version>${fit.version}</version> | ||
| <scope>runtime</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.fitframework.plugin</groupId> | ||
| <artifactId>fit-service-discovery</artifactId> | ||
| <version>${fit.version}</version> | ||
| <scope>runtime</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.fitframework.plugin</groupId> | ||
| <artifactId>fit-service-coordination-locator</artifactId> | ||
| <version>${fit.version}</version> | ||
| <scope>runtime</scope> | ||
| </dependency> | ||
| <!-- 注册中心的内nacos版实现 --> | ||
| <dependency> | ||
| <groupId>org.fitframework.plugin</groupId> | ||
| <artifactId>fit-service-coordination-nacos</artifactId> | ||
| <version>${fit.version}</version> | ||
| <scope>runtime</scope> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <version>${maven.compiler.version}</version> | ||
| <configuration> | ||
| <source>${java.version}</source> | ||
| <target>${java.version}</target> | ||
| <encoding>${project.build.sourceEncoding}</encoding> | ||
| <compilerArgs> | ||
| <arg>-parameters</arg> | ||
| </compilerArgs> | ||
| </configuration> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.fitframework</groupId> | ||
| <artifactId>fit-build-maven-plugin</artifactId> | ||
| <version>${fit.version}</version> | ||
| <executions> | ||
| <execution> | ||
| <id>package-app</id> | ||
| <goals> | ||
| <goal>package-app</goal> | ||
| </goals> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> | ||
25 changes: 25 additions & 0 deletions
25
...omplicated-apps/app-assistant/src/main/java/modelengine/fit/example/AssistantStarter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved. | ||
| * This file is a part of the ModelEngine Project. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| package modelengine.fit.example; | ||
|
|
||
| import modelengine.fitframework.annotation.Component; | ||
| import modelengine.fitframework.annotation.ScanPackages; | ||
| import modelengine.fitframework.runtime.FitStarter; | ||
|
|
||
| /** | ||
| * 启动类。 | ||
| * | ||
| * @author 董智豪 | ||
| * @since 2025-06-21 | ||
| */ | ||
| @Component | ||
| @ScanPackages("modelengine") | ||
| public class AssistantStarter { | ||
| public static void main(String[] args) { | ||
| FitStarter.start(AssistantStarter.class, args); | ||
| } | ||
| } |
37 changes: 37 additions & 0 deletions
37
...s/app-assistant/src/main/java/modelengine/fit/example/controller/AssistantController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved. | ||
| * This file is a part of the ModelEngine Project. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| package modelengine.fit.example.controller; | ||
|
|
||
| import modelengine.fit.example.Weather; | ||
| import modelengine.fit.http.annotation.GetMapping; | ||
| import modelengine.fitframework.annotation.Component; | ||
| import modelengine.fitframework.annotation.Fit; | ||
|
|
||
| /** | ||
| * 表示助手的控制器。 | ||
| * | ||
| * @author 董智豪 | ||
| * @since 2025-06-21 | ||
| */ | ||
| @Component | ||
| public class AssistantController { | ||
| private final Weather weather; | ||
|
|
||
| public AssistantController(@Fit Weather weather) { | ||
| this.weather = weather; | ||
| } | ||
|
|
||
| /** | ||
| * 获取天气信息。 | ||
| * | ||
| * @return 表示天气信息的 {@link String}。 | ||
| */ | ||
| @GetMapping(path = "/weather") | ||
| public String getWeather() { | ||
| return this.weather.get(); | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
...es/fit-example/08-nacos-complicated-apps/app-assistant/src/main/resources/application.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| application: | ||
| name: 'assistant' | ||
|
|
||
| worker: | ||
| id: 'assistant' | ||
| host: '127.0.0.1' | ||
| environment: 'local' | ||
| environment-sequence: 'local' | ||
|
|
||
| matata: | ||
| registry: | ||
| mode: 'PROXY' | ||
| host: '127.0.0.1' | ||
| port: 8848 | ||
| environment: 'local' | ||
|
|
||
| server: | ||
| http: | ||
| port: 8080 |
115 changes: 115 additions & 0 deletions
115
examples/fit-example/08-nacos-complicated-apps/app-default-weather/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <groupId>org.fitframework.example</groupId> | ||
| <artifactId>nacos-default-weather-for-complicated</artifactId> | ||
| <version>1.0-SNAPSHOT</version> | ||
|
|
||
| <properties> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| <java.version>17</java.version> | ||
|
|
||
| <!-- FIT version --> | ||
| <fit.version>3.6.0-SNAPSHOT</fit.version> | ||
|
|
||
| <!-- Maven plugin versions --> | ||
| <maven.compiler.version>3.14.0</maven.compiler.version> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.fitframework.example</groupId> | ||
| <artifactId>nacos-weather-for-complicated</artifactId> | ||
| <version>1.0-SNAPSHOT</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.fitframework</groupId> | ||
| <artifactId>fit-starter</artifactId> | ||
| <version>${fit.version}</version> | ||
| </dependency> | ||
|
|
||
| <!-- FIT plugins --> | ||
| <dependency> | ||
| <groupId>org.fitframework</groupId> | ||
| <artifactId>fit-plugins-starter-web</artifactId> | ||
| <version>${fit.version}</version> | ||
| </dependency> | ||
|
|
||
| <!-- 不在默认插件集合中的插件列表 --> | ||
| <dependency> | ||
| <groupId>org.fitframework.plugin</groupId> | ||
| <artifactId>fit-client-http</artifactId> | ||
| <version>${fit.version}</version> | ||
| <scope>runtime</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.fitframework.plugin</groupId> | ||
| <artifactId>fit-http-client-okhttp</artifactId> | ||
| <version>${fit.version}</version> | ||
| <scope>runtime</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.fitframework.plugin</groupId> | ||
| <artifactId>fit-heartbeat-client</artifactId> | ||
| <version>${fit.version}</version> | ||
| <scope>runtime</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.fitframework.plugin</groupId> | ||
| <artifactId>fit-service-registry</artifactId> | ||
| <version>${fit.version}</version> | ||
| <scope>runtime</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.fitframework.plugin</groupId> | ||
| <artifactId>fit-service-discovery</artifactId> | ||
| <version>${fit.version}</version> | ||
| <scope>runtime</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.fitframework.plugin</groupId> | ||
| <artifactId>fit-service-coordination-locator</artifactId> | ||
| <version>${fit.version}</version> | ||
| <scope>runtime</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.fitframework.plugin</groupId> | ||
| <artifactId>fit-service-coordination-nacos</artifactId> | ||
| <version>${fit.version}</version> | ||
| <scope>runtime</scope> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <version>${maven.compiler.version}</version> | ||
| <configuration> | ||
| <source>${java.version}</source> | ||
| <target>${java.version}</target> | ||
| <encoding>${project.build.sourceEncoding}</encoding> | ||
| <compilerArgs> | ||
| <arg>-parameters</arg> | ||
| </compilerArgs> | ||
| </configuration> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.fitframework</groupId> | ||
| <artifactId>fit-build-maven-plugin</artifactId> | ||
| <version>${fit.version}</version> | ||
| <executions> | ||
| <execution> | ||
| <id>package-app</id> | ||
| <goals> | ||
| <goal>package-app</goal> | ||
| </goals> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> |
25 changes: 25 additions & 0 deletions
25
...icated-apps/app-default-weather/src/main/java/modelengine/fit/example/DefaultWeather.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved. | ||
| * This file is a part of the ModelEngine Project. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| package modelengine.fit.example; | ||
|
|
||
| import modelengine.fitframework.annotation.Component; | ||
| import modelengine.fitframework.annotation.Fitable; | ||
|
|
||
| /** | ||
| * 表示 {@link Weather} 的默认实现。 | ||
| * | ||
| * @author 董智豪 | ||
| * @since 2025-06-21 | ||
| */ | ||
| @Component | ||
| public class DefaultWeather implements Weather { | ||
| @Override | ||
| @Fitable(id = "default-weather") | ||
| public String get() { | ||
| return "Default weather application is working."; | ||
| } | ||
| } |
25 changes: 25 additions & 0 deletions
25
...apps/app-default-weather/src/main/java/modelengine/fit/example/DefaultWeatherStarter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved. | ||
| * This file is a part of the ModelEngine Project. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| package modelengine.fit.example; | ||
|
|
||
| import modelengine.fitframework.annotation.Component; | ||
| import modelengine.fitframework.annotation.ScanPackages; | ||
| import modelengine.fitframework.runtime.FitStarter; | ||
|
|
||
| /** | ||
| * 启动类。 | ||
| * | ||
| * @author 董智豪 | ||
| * @since 2025-06-21 | ||
| */ | ||
| @Component | ||
| @ScanPackages("modelengine") | ||
| public class DefaultWeatherStarter { | ||
| public static void main(String[] args) { | ||
| FitStarter.start(DefaultWeatherStarter.class, args); | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
...-example/08-nacos-complicated-apps/app-default-weather/src/main/resources/application.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| application: | ||
| name: 'default-weather' | ||
|
|
||
| worker: | ||
| id: 'default-weather' | ||
| host: '127.0.0.1' | ||
| environment: 'local' | ||
| environment-sequence: 'local' | ||
|
|
||
| matata: | ||
| registry: | ||
| mode: 'PROXY' | ||
| host: '127.0.0.1' | ||
| port: 8848 | ||
| environment: 'local' | ||
|
|
||
| server: | ||
| http: | ||
| port: 8081 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.