Skip to content

feat:support push gateway event. #578

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
merged 2 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions polaris-assembly/polaris-assembly-factory/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@
<artifactId>event-tsf</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.tencent.polaris</groupId>
<artifactId>event-pushgateway</artifactId>
<version>${project.version}</version>
</dependency>

<!--测试依赖插件-->
<dependency>
Expand Down
5 changes: 5 additions & 0 deletions polaris-circuitbreaker/polaris-circuitbreaker-factory/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
<artifactId>event-tsf</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.tencent.polaris</groupId>
<artifactId>event-pushgateway</artifactId>
<version>${project.version}</version>
</dependency>

<!--健康检查插件-->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ global:
tsf:
# 描述:TSF 事件上报开关
enable: false
# 描述:PushGateway 事件上报插件配置
pushgateway:
# 描述:PushGateway 事件上报开关
enable: false
# 描述:PushGateway 事件上报队列长度
eventQueueSize: 10000;
# 描述:PushGateway 事件上报最大批量大小
maxBatchSize: 100
# 描述:Admin相关的配置
admin:
# 描述:Admin的监听的IP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public interface DefaultPlugins {
*/
String TSF_EVENT_REPORTER_TYPE = "tsf";

/**
* PushGateway 事件上报插件名
*/
String PUSH_GATEWAY_EVENT_REPORTER_TYPE = "pushgateway";

/**
* 黑白名单鉴权插件名
*/
Expand Down
5 changes: 5 additions & 0 deletions polaris-configuration/polaris-configuration-factory/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@
<artifactId>event-tsf</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.tencent.polaris</groupId>
<artifactId>event-pushgateway</artifactId>
<version>${project.version}</version>
</dependency>
<!--配置加密插件-->
<dependency>
<groupId>com.tencent.polaris</groupId>
Expand Down
5 changes: 5 additions & 0 deletions polaris-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,11 @@
<artifactId>event-tsf</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.tencent.polaris</groupId>
<artifactId>event-pushgateway</artifactId>
<version>${project.version}</version>
</dependency>
<!-- polaris-plugins-ratelimiter-->
<dependency>
<groupId>com.tencent.polaris</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ private InstanceRegisterResponse doRegister(InstanceRegisterRequest req, Map<Str
response.getInstanceID());
serviceCallResult.setRetStatus(RetStatus.RetSuccess);
serviceCallResult.setRetCode(ErrorCode.Success.getCode());
sdkContext.getValueContext().setPort(req.getPort());
sdkContext.getValueContext().setInstanceId(response.getInstanceID());
return new InstanceRegisterResponse(response.getInstanceID(), response.isExists());
} catch (PolarisException e) {
serviceCallResult.setRetStatus(RetStatus.RetFail);
Expand Down
5 changes: 5 additions & 0 deletions polaris-discovery/polaris-discovery-factory/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@
<artifactId>event-tsf</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.tencent.polaris</groupId>
<artifactId>event-pushgateway</artifactId>
<version>${project.version}</version>
</dependency>

<!--测试依赖插件-->
<dependency>
Expand Down
6 changes: 6 additions & 0 deletions polaris-distribution/polaris-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
<artifactId>bcpkix-jdk15to18</artifactId>
<version>${bouncycastle.version}</version>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
<version>${otel.version}</version>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -180,6 +185,7 @@
<artifactSet>
<excludes>
<exclude>org.bouncycastle:*</exclude>
<exclude>io.opentelemetry:*</exclude>
</excludes>
</artifactSet>
</configuration>
Expand Down
9 changes: 7 additions & 2 deletions polaris-plugins/polaris-plugin-api/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?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">
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">
<parent>
<artifactId>polaris-plugins</artifactId>
<groupId>com.tencent.polaris</groupId>
Expand All @@ -16,6 +16,11 @@
<description>Polaris Plugin API JAR</description>

<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.tencent.polaris</groupId>
<artifactId>polaris-config</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
package com.tencent.polaris.api.plugin.common;

import com.tencent.polaris.logging.LoggerFactory;
import org.slf4j.Logger;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;

/**
* 用于主流程传递kv数据的上下文对象,线程安全
Expand All @@ -33,8 +34,12 @@ public class ValueContext {

private static final String KEY_HOST = "key_host";

private static final String KEY_PORT = "key_port";

private static final String KEY_CLIENT_ID = "key_clientId";

private static final String KEY_INSTANCE_ID = "key_instanceId";

private static final String KEY_ENGINE = "key_engine";

private static final String KEY_SERVER_CONNECTOR_PROTOCOL = "key_serverConnectorProtocol";
Expand Down Expand Up @@ -88,6 +93,14 @@ public void setHost(String host) {
setValue(KEY_HOST, host);
}

public Integer getPort() {
return getValue(KEY_PORT);
}

public void setPort(Integer port) {
setValue(KEY_PORT, port);
}

public String getClientId() {
return getValue(KEY_CLIENT_ID);
}
Expand All @@ -96,6 +109,14 @@ public void setClientId(String clientId) {
setValue(KEY_CLIENT_ID, clientId);
}

public String getInstanceId() {
return getValue(KEY_INSTANCE_ID);
}

public void setInstanceId(String instanceId) {
setValue(KEY_INSTANCE_ID, instanceId);
}

public String getServerConnectorProtocol() {
return getValue(KEY_SERVER_CONNECTOR_PROTOCOL);
}
Expand Down
Loading