Skip to content

Commit 2598bdf

Browse files
committed
[fit] 增加fit-server-coordination-nacos内置插件
1 parent 7b9a04e commit 2598bdf

7 files changed

Lines changed: 694 additions & 0 deletions

File tree

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
4+
~ This file is a part of the ModelEngine Project.
5+
~ Licensed under the MIT License. See License.txt in the project root for license information.
6+
-->
7+
8+
<project xmlns="http://maven.apache.org/POM/4.0.0"
9+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
11+
<modelVersion>4.0.0</modelVersion>
12+
<parent>
13+
<groupId>org.fitframework.plugin</groupId>
14+
<artifactId>fit-plugin-parent</artifactId>
15+
<version>3.6.0-SNAPSHOT</version>
16+
</parent>
17+
18+
<artifactId>fit-service-coordination-nacos</artifactId>
19+
20+
<name>FIT Service Coordination Nacos</name>
21+
<description>FIT Framework Service Coordination Nacos Plugin module provides a nacos-based implementation of FIT service
22+
registry center.
23+
</description>
24+
<url>https://github.com/ModelEngine-Group/fit-framework</url>
25+
26+
<dependencies>
27+
<!-- nacos-client -->
28+
<dependency>
29+
<groupId>com.alibaba.nacos</groupId>
30+
<artifactId>nacos-client</artifactId>
31+
<version>3.0.1</version>
32+
</dependency>
33+
<!-- FIT core -->
34+
<dependency>
35+
<groupId>org.fitframework</groupId>
36+
<artifactId>fit-api</artifactId>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.fitframework</groupId>
40+
<artifactId>fit-util</artifactId>
41+
</dependency>
42+
43+
<!-- Services -->
44+
<dependency>
45+
<groupId>org.fitframework.service</groupId>
46+
<artifactId>fit-heartbeat</artifactId>
47+
</dependency>
48+
<dependency>
49+
<groupId>org.fitframework.service</groupId>
50+
<artifactId>fit-service-registry-and-discovery</artifactId>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.fitframework.service</groupId>
54+
<artifactId>fit-http-classic</artifactId>
55+
</dependency>
56+
57+
<!-- Test -->
58+
<dependency>
59+
<groupId>org.junit.jupiter</groupId>
60+
<artifactId>junit-jupiter</artifactId>
61+
<scope>test</scope>
62+
</dependency>
63+
<dependency>
64+
<groupId>org.mockito</groupId>
65+
<artifactId>mockito-core</artifactId>
66+
<scope>test</scope>
67+
</dependency>
68+
<dependency>
69+
<groupId>org.assertj</groupId>
70+
<artifactId>assertj-core</artifactId>
71+
<scope>test</scope>
72+
</dependency>
73+
<!-- tool -->
74+
<dependency>
75+
<groupId>org.projectlombok</groupId>
76+
<artifactId>lombok</artifactId>
77+
</dependency>
78+
</dependencies>
79+
80+
<build>
81+
<plugins>
82+
<plugin>
83+
<groupId>org.apache.maven.plugins</groupId>
84+
<artifactId>maven-antrun-plugin</artifactId>
85+
<executions>
86+
<execution>
87+
<phase>package</phase>
88+
<configuration>
89+
<target>
90+
<copy file="${project.build.directory}/${project.build.finalName}.jar"
91+
todir="../../../../../../build/plugins"/>
92+
</target>
93+
</configuration>
94+
<goals>
95+
<goal>run</goal>
96+
</goals>
97+
</execution>
98+
</executions>
99+
</plugin>
100+
</plugins>
101+
</build>
102+
103+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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.heartbeat.server;
8+
9+
import lombok.Data;
10+
import modelengine.fitframework.annotation.AcceptConfigValues;
11+
import modelengine.fitframework.annotation.Component;
12+
import modelengine.fitframework.conf.Config;
13+
14+
/**
15+
*
16+
* @author mikeaaaaaa
17+
* @description
18+
* @created 2025/6/14
19+
*/
20+
@Component
21+
@AcceptConfigValues("nacos.heartbeat")
22+
@Data
23+
public class HeartbeatConfig {
24+
25+
/**
26+
* 是否为临时实例,默认为 true。
27+
* 临时实例在服务注销后会自动从注册中心移除。
28+
*/
29+
private Boolean isEphemeral = true;
30+
31+
/**
32+
* 服务权重,默认为 1.0。
33+
* 用于负载均衡时的权重计算。
34+
*/
35+
private Float weight = 1.0F;
36+
37+
/**
38+
* 心跳间隔时间(单位:秒)。
39+
* 定义服务发送心跳的时间间隔。
40+
*/
41+
private Integer heartBeatInterval;
42+
43+
/**
44+
* 心跳超时时间(单位:秒)。
45+
* 定义服务在未收到心跳后判定为超时的时间。
46+
*/
47+
private Integer heartBeatTimeout;
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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.heartbeat.server;
8+
9+
import modelengine.fit.heartbeat.HeartbeatService;
10+
import modelengine.fitframework.annotation.Component;
11+
import modelengine.fitframework.annotation.Fitable;
12+
13+
import java.util.List;
14+
15+
/**
16+
* 用于提供心跳相关的服务。
17+
*
18+
* @author mikeaaaaaa
19+
* @since 2025/6/4
20+
*/
21+
@Component
22+
public class HeartbeatServer implements HeartbeatService {
23+
@Override
24+
@Fitable(id = "DBC9E2F7C0E443F1AC986BBC3D58C27B")
25+
public Boolean sendHeartbeat(List<HeartbeatInfo> heartbeatInfo, Address address) {
26+
return true;
27+
}
28+
29+
@Override
30+
public Boolean stopHeartbeat(List<HeartbeatInfo> heartbeatInfo, Address address) {
31+
return true;
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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.service.server;
8+
9+
import lombok.AllArgsConstructor;
10+
import lombok.Builder;
11+
import lombok.Data;
12+
import lombok.NoArgsConstructor;
13+
import modelengine.fitframework.annotation.AcceptConfigValues;
14+
import modelengine.fitframework.annotation.Component;
15+
16+
/**
17+
* @author mikeaaaaaa
18+
* @description
19+
* @created 2025/6/14
20+
*/
21+
@Component
22+
@AcceptConfigValues("nacos")
23+
@Data
24+
public class NacosConfig {
25+
/**
26+
* Nacos服务器地址
27+
*/
28+
private String serverAddr;
29+
30+
/**
31+
* 登录用户名
32+
*/
33+
private String username;
34+
35+
/**
36+
* 登录密码
37+
*/
38+
private String password;
39+
40+
/**
41+
* 访问密钥
42+
*/
43+
private String accessKey;
44+
45+
/**
46+
* 秘钥
47+
*/
48+
private String secretKey;
49+
50+
/**
51+
* 命名空间
52+
*/
53+
private String namespace;
54+
}
55+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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.service.server;
8+
9+
/**
10+
* @author pc
11+
* @description
12+
* @created 2025/6/20
13+
*/
14+
15+
import modelengine.fit.service.entity.FitableAddressInstance;
16+
import modelengine.fitframework.annotation.Genericable;
17+
18+
import java.util.List;
19+
20+
/**
21+
* 表示运行时 {@code 'worker.'} 前缀的配置项。
22+
*
23+
* @author 董智豪
24+
* @since 2025-06-20
25+
*/
26+
public interface Notify {
27+
28+
@Genericable(id = "b69df5e8cbcd4166aa5029602e7a58cf")
29+
void notifyFitables(List<FitableAddressInstance> fitableInstances);
30+
}

0 commit comments

Comments
 (0)