From 802b648b9d4c4912df93c7822f9fa7472dbe81ec Mon Sep 17 00:00:00 2001 From: liguangling <18740203460@163.com> Date: Sat, 2 Sep 2023 19:47:23 +0800 Subject: [PATCH] feature:check the required fields etcd when the Config mode starts(#1439) --- .../dynamic/api/BootstrapPropertiesInterface.java | 7 +++++++ .../core/enable/BeforeCheckConfiguration.java | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/kernel/dynamic/api/src/main/java/cn/hippo4j/threadpool/dynamic/api/BootstrapPropertiesInterface.java b/kernel/dynamic/api/src/main/java/cn/hippo4j/threadpool/dynamic/api/BootstrapPropertiesInterface.java index 5ad4578b..fe514c83 100644 --- a/kernel/dynamic/api/src/main/java/cn/hippo4j/threadpool/dynamic/api/BootstrapPropertiesInterface.java +++ b/kernel/dynamic/api/src/main/java/cn/hippo4j/threadpool/dynamic/api/BootstrapPropertiesInterface.java @@ -79,4 +79,11 @@ public interface BootstrapPropertiesInterface { default Map getNacos() { return null; } + + /** + * Get etcd. + */ + default Map getEtcd() { + return null; + } } diff --git a/threadpool/core/src/main/java/cn/hippo4j/core/enable/BeforeCheckConfiguration.java b/threadpool/core/src/main/java/cn/hippo4j/core/enable/BeforeCheckConfiguration.java index 28665523..65f0cb5d 100644 --- a/threadpool/core/src/main/java/cn/hippo4j/core/enable/BeforeCheckConfiguration.java +++ b/threadpool/core/src/main/java/cn/hippo4j/core/enable/BeforeCheckConfiguration.java @@ -91,6 +91,21 @@ public class BeforeCheckConfiguration { "Please check whether the [spring.dynamic.thread-pool.nacos.data-id] configuration is empty or an empty string."); } } + Map etcd = properties.getEtcd(); + if (MapUtil.isNotEmpty(etcd)){ + String endpoints = etcd.get("endpoints"); + if ((StringUtil.isBlank(endpoints))){ + throw new ConfigEmptyException( + "Web server failed to start. The dynamic thread pool etcd endpoints is empty.", + "Please check whether the [spring.dynamic.thread-pool.etcd.endpoints] configuration is empty or an empty string."); + } + String key = etcd.get("key"); + if ((StringUtil.isBlank(key))){ + throw new ConfigEmptyException( + "Web server failed to start. The dynamic thread pool etcd key is empty.", + "Please check whether the [spring.dynamic.thread-pool.etcd.key] configuration is empty or an empty string."); + } + } break; } default: