diff --git a/joylive-package/src/main/assembly/config/config.yaml b/joylive-package/src/main/assembly/config/config.yaml
index 79e76cae..c7fdc821 100644
--- a/joylive-package/src/main/assembly/config/config.yaml
+++ b/joylive-package/src/main/assembly/config/config.yaml
@@ -111,6 +111,8 @@ agent:
counter:
enabled: true
governance:
+ service:
+ warmups: ${CONFIG_WARMUP_SERVICES:}
initializeTimeout: ${CONFIG_POLICY_INITIALIZE_TIMEOUT:10000}
router:
virtual: ${CONFIG_VIRTUAL_SIZE:500}
diff --git a/joylive-plugin/joylive-registry/joylive-registry-springcloud3/pom.xml b/joylive-plugin/joylive-registry/joylive-registry-springcloud3/pom.xml
index 229ef5c6..e9340866 100644
--- a/joylive-plugin/joylive-registry/joylive-registry-springcloud3/pom.xml
+++ b/joylive-plugin/joylive-registry/joylive-registry-springcloud3/pom.xml
@@ -12,10 +12,9 @@
joylive-registry-springcloud3
- plugin
3.1.8
- 5.3.31
+
org.springframework.cloud
@@ -23,6 +22,18 @@
${spring.cloud.version}
provided
+
+ org.springframework.cloud
+ spring-cloud-loadbalancer
+ ${spring.cloud.version}
+
+
+ org.glassfish
+ jakarta.el
+
+
+ provided
+
org.springframework.cloud
spring-cloud-openfeign-core
diff --git a/joylive-plugin/joylive-registry/joylive-registry-springcloud3/src/main/java/com/jd/live/agent/plugin/registry/springcloud/v3/definition/DiscoveryClientDefinition.java b/joylive-plugin/joylive-registry/joylive-registry-springcloud3/src/main/java/com/jd/live/agent/plugin/registry/springcloud/v3/definition/DiscoveryClientDefinition.java
new file mode 100644
index 00000000..82209628
--- /dev/null
+++ b/joylive-plugin/joylive-registry/joylive-registry-springcloud3/src/main/java/com/jd/live/agent/plugin/registry/springcloud/v3/definition/DiscoveryClientDefinition.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright © ${year} ${owner} (${email})
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jd.live.agent.plugin.registry.springcloud.v3.definition;
+
+import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder;
+import com.jd.live.agent.core.extension.annotation.*;
+import com.jd.live.agent.core.inject.annotation.Inject;
+import com.jd.live.agent.core.inject.annotation.Injectable;
+import com.jd.live.agent.core.plugin.definition.InterceptorDefinition;
+import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter;
+import com.jd.live.agent.core.plugin.definition.PluginDefinition;
+import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter;
+import com.jd.live.agent.governance.config.GovernanceConfig;
+import com.jd.live.agent.governance.policy.PolicySupplier;
+import com.jd.live.agent.plugin.registry.springcloud.v3.interceptor.DiscoveryClientInterceptor;
+
+/**
+ * ServiceRegistryDefinition
+ *
+ * @author Zhiguo.Chen
+ * @since 1.0.0
+ */
+@Injectable
+@Extension(value = "DiscoveryClientDefinition_v3", order = PluginDefinition.ORDER_REGISTRY)
+@ConditionalOnProperties(value = {
+ @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true),
+ @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true),
+ @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true)
+}, relation = ConditionalRelation.OR)
+@ConditionalOnClass(DiscoveryClientDefinition.TYPE_DISCOVERY_CLIENT)
+public class DiscoveryClientDefinition extends PluginDefinitionAdapter {
+
+ protected static final String TYPE_DISCOVERY_CLIENT = "org.springframework.cloud.loadbalancer.core.DiscoveryClientServiceInstanceListSupplier";
+
+ @Inject(PolicySupplier.COMPONENT_POLICY_SUPPLIER)
+ private PolicySupplier policySupplier;
+
+ public DiscoveryClientDefinition() {
+ this.matcher = () -> MatcherBuilder.isImplement(TYPE_DISCOVERY_CLIENT);
+ this.interceptors = new InterceptorDefinition[]{
+ new InterceptorDefinitionAdapter(
+ MatcherBuilder.isConstructor(),
+ () -> new DiscoveryClientInterceptor(policySupplier))
+ };
+ }
+}
diff --git a/joylive-plugin/joylive-registry/joylive-registry-springcloud3/src/main/java/com/jd/live/agent/plugin/registry/springcloud/v3/interceptor/DiscoveryClientInterceptor.java b/joylive-plugin/joylive-registry/joylive-registry-springcloud3/src/main/java/com/jd/live/agent/plugin/registry/springcloud/v3/interceptor/DiscoveryClientInterceptor.java
new file mode 100644
index 00000000..d7d87737
--- /dev/null
+++ b/joylive-plugin/joylive-registry/joylive-registry-springcloud3/src/main/java/com/jd/live/agent/plugin/registry/springcloud/v3/interceptor/DiscoveryClientInterceptor.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright © ${year} ${owner} (${email})
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jd.live.agent.plugin.registry.springcloud.v3.interceptor;
+
+import com.jd.live.agent.bootstrap.bytekit.context.ExecutableContext;
+import com.jd.live.agent.bootstrap.logger.Logger;
+import com.jd.live.agent.bootstrap.logger.LoggerFactory;
+import com.jd.live.agent.core.plugin.definition.InterceptorAdaptor;
+import com.jd.live.agent.governance.policy.PolicySupplier;
+import com.jd.live.agent.governance.policy.PolicyType;
+import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+/**
+ * ServiceRegistryInterceptor
+ *
+ * @author Zhiguo.Chen
+ * @since 1.0.0
+ */
+public class DiscoveryClientInterceptor extends InterceptorAdaptor {
+
+ private static final Logger logger = LoggerFactory.getLogger(ServiceRegistryInterceptor.class);
+
+ private final PolicySupplier policySupplier;
+
+ public DiscoveryClientInterceptor(PolicySupplier policySupplier) {
+ this.policySupplier = policySupplier;
+ }
+
+ @Override
+ public void onSuccess(ExecutableContext ctx) {
+ ServiceInstanceListSupplier supplier = (ServiceInstanceListSupplier) ctx.getTarget();
+ subscribePolicy(supplier.getServiceId());
+ }
+
+ private void subscribePolicy(String serviceId) {
+ try {
+ policySupplier.subscribe(serviceId, PolicyType.SERVICE_POLICY).get(5000, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException ignore) {
+ } catch (ExecutionException e) {
+ Throwable cause = e.getCause() != null ? e.getCause() : e;
+ logger.warn("Failed to get governance policy for " + serviceId + ", caused by " + e.getMessage(), e);
+ } catch (TimeoutException e) {
+ logger.warn("Failed to get governance policy for " + serviceId + ", caused by it's timeout.");
+ }
+ }
+}
diff --git a/joylive-plugin/joylive-registry/joylive-registry-springcloud3/src/main/resources/META-INF/services/com.jd.live.agent.core.plugin.definition.PluginDefinition b/joylive-plugin/joylive-registry/joylive-registry-springcloud3/src/main/resources/META-INF/services/com.jd.live.agent.core.plugin.definition.PluginDefinition
index a96e2c8b..de60d848 100644
--- a/joylive-plugin/joylive-registry/joylive-registry-springcloud3/src/main/resources/META-INF/services/com.jd.live.agent.core.plugin.definition.PluginDefinition
+++ b/joylive-plugin/joylive-registry/joylive-registry-springcloud3/src/main/resources/META-INF/services/com.jd.live.agent.core.plugin.definition.PluginDefinition
@@ -1,2 +1,3 @@
com.jd.live.agent.plugin.registry.springcloud.v3.definition.ServiceRegistryDefinition
-com.jd.live.agent.plugin.registry.springcloud.v3.definition.FeignClientFactoryBeanDefinition
\ No newline at end of file
+com.jd.live.agent.plugin.registry.springcloud.v3.definition.FeignClientFactoryBeanDefinition
+com.jd.live.agent.plugin.registry.springcloud.v3.definition.DiscoveryClientDefinition
\ No newline at end of file