diff --git a/powerjob-worker-samples/src/main/resources/application.properties b/powerjob-worker-samples/src/main/resources/application.properties index ceb6fda9..67f705c7 100644 --- a/powerjob-worker-samples/src/main/resources/application.properties +++ b/powerjob-worker-samples/src/main/resources/application.properties @@ -4,7 +4,7 @@ spring.jpa.open-in-view=false # Whether to enable PowerJob Worker, default is true powerjob.worker.enabled=true # Turn on test mode and do not force the server connection to be verified -powerjob.worker.enable-test-mode=false +powerjob.worker.allow-lazy-connect-server=false # Transport port, default is 27777 powerjob.worker.port=27777 # Application name, used for grouping applications. Recommend to set the same value as project name. diff --git a/powerjob-worker-spring-boot-starter/src/main/java/tech/powerjob/worker/autoconfigure/PowerJobAutoConfiguration.java b/powerjob-worker-spring-boot-starter/src/main/java/tech/powerjob/worker/autoconfigure/PowerJobAutoConfiguration.java index abc1d957..2687a281 100644 --- a/powerjob-worker-spring-boot-starter/src/main/java/tech/powerjob/worker/autoconfigure/PowerJobAutoConfiguration.java +++ b/powerjob-worker-spring-boot-starter/src/main/java/tech/powerjob/worker/autoconfigure/PowerJobAutoConfiguration.java @@ -72,7 +72,7 @@ public class PowerJobAutoConfiguration { * When enabledTestMode is set as true, PowerJob-worker no longer connects to PowerJob-server * or validate appName. */ - config.setEnableTestMode(worker.isEnableTestMode()); + config.setAllowLazyConnectServer(worker.isAllowLazyConnectServer()); /* * Max length of appended workflow context . Appended workflow context value that is longer than the value will be ignored. */ diff --git a/powerjob-worker-spring-boot-starter/src/main/java/tech/powerjob/worker/autoconfigure/PowerJobProperties.java b/powerjob-worker-spring-boot-starter/src/main/java/tech/powerjob/worker/autoconfigure/PowerJobProperties.java index 5ac4181e..fe054e1e 100644 --- a/powerjob-worker-spring-boot-starter/src/main/java/tech/powerjob/worker/autoconfigure/PowerJobProperties.java +++ b/powerjob-worker-spring-boot-starter/src/main/java/tech/powerjob/worker/autoconfigure/PowerJobProperties.java @@ -81,14 +81,14 @@ public class PowerJobProperties { } @Deprecated - @DeprecatedConfigurationProperty(replacement = "powerjob.worker.enable-test-mode") + @DeprecatedConfigurationProperty(replacement = "powerjob.worker.allow-lazy-connect-server") public boolean isEnableTestMode() { - return getWorker().enableTestMode; + return getWorker().isAllowLazyConnectServer(); } @Deprecated public void setEnableTestMode(boolean enableTestMode) { - getWorker().setEnableTestMode(enableTestMode); + getWorker().setAllowLazyConnectServer(enableTestMode); } /** @@ -146,10 +146,10 @@ public class PowerJobProperties { */ private int maxResultLength = 8192; /** - * If test mode is set as true, Powerjob-worker no longer connects to the server or validates appName. - * Test mode is used for conditions that your have no powerjob-server in your develop env, so you can't start up the application + * If allowLazyConnectServer is set as true, PowerJob worker allows launching without a direct connection to the server. + * allowLazyConnectServer is used for conditions that your have no powerjob-server in your develop env so you can't startup the application */ - private boolean enableTestMode = false; + private boolean allowLazyConnectServer = false; /** * Max length of appended workflow context value length. Appended workflow context value that is longer than the value will be ignored. * {@link WorkflowContext} max length for #appendedContextData diff --git a/powerjob-worker/src/main/java/tech/powerjob/worker/background/discovery/PowerJobServerDiscoveryService.java b/powerjob-worker/src/main/java/tech/powerjob/worker/background/discovery/PowerJobServerDiscoveryService.java index 11db7074..b474dd29 100644 --- a/powerjob-worker/src/main/java/tech/powerjob/worker/background/discovery/PowerJobServerDiscoveryService.java +++ b/powerjob-worker/src/main/java/tech/powerjob/worker/background/discovery/PowerJobServerDiscoveryService.java @@ -65,8 +65,8 @@ public class PowerJobServerDiscoveryService implements ServerDiscoveryService { try { return assertApp0(); } catch (Exception e) { - if (config.isEnableTestMode()) { - log.warn("[PowerJobWorker] using TestMode now, it's dangerous if this is production env."); + if (config.isAllowLazyConnectServer()) { + log.warn("[PowerJobWorker] worker is not currently connected to the server, and because allowLazyConnectServer is configured to true it won't block the startup, but you have to be aware that this is dangerous in production environments!"); // 返回引用,方便后续更新对象内属性 return appInfo; @@ -123,7 +123,7 @@ public class PowerJobServerDiscoveryService implements ServerDiscoveryService { @Override public void timingCheck(ScheduledExecutorService timingPool) { this.currentServerAddress = discovery(); - if (StringUtils.isEmpty(this.currentServerAddress) && !config.isEnableTestMode()) { + if (StringUtils.isEmpty(this.currentServerAddress) && !config.isAllowLazyConnectServer()) { throw new PowerJobException("can't find any available server, this worker has been quarantined."); } // 这里必须保证成功 diff --git a/powerjob-worker/src/main/java/tech/powerjob/worker/common/PowerJobWorkerConfig.java b/powerjob-worker/src/main/java/tech/powerjob/worker/common/PowerJobWorkerConfig.java index c9238d1c..cb34853b 100644 --- a/powerjob-worker/src/main/java/tech/powerjob/worker/common/PowerJobWorkerConfig.java +++ b/powerjob-worker/src/main/java/tech/powerjob/worker/common/PowerJobWorkerConfig.java @@ -57,10 +57,10 @@ public class PowerJobWorkerConfig { */ private StoreStrategy storeStrategy = StoreStrategy.DISK; /** - * If test mode is set as true, Powerjob-worker no longer connects to the server or validates appName. - * Test mode is used for conditions that your have no powerjob-server in your develop env so you can't startup the application + * If allowLazyConnectServer is set as true, PowerJob worker allows launching without a direct connection to the server. + * allowLazyConnectServer is used for conditions that your have no powerjob-server in your develop env so you can't startup the application */ - private boolean enableTestMode = false; + private boolean allowLazyConnectServer = false; /** * Max length of appended workflow context value length. Appended workflow context value that is longer than the value will be ignore. * {@link WorkflowContext} max length for #appendedContextData