Commit 74f29998 by 赵天增

补充注释

parent 554b9508
...@@ -18,6 +18,7 @@ package de.codecentric.boot.admin.client.registration; ...@@ -18,6 +18,7 @@ package de.codecentric.boot.admin.client.registration;
import java.time.Duration; import java.time.Duration;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.DisposableBean;
...@@ -32,6 +33,8 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; ...@@ -32,6 +33,8 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
/** /**
* Listener responsible for starting and stopping the registration task when the application is * Listener responsible for starting and stopping the registration task when the application is
* ready. * ready.
* <p>
* 监听器负责在应用程序准备就绪时启动和停止注册任务
* *
* @author Johannes Edmeier * @author Johannes Edmeier
*/ */
...@@ -82,6 +85,9 @@ public class RegistrationApplicationListener implements InitializingBean, Dispos ...@@ -82,6 +85,9 @@ public class RegistrationApplicationListener implements InitializingBean, Dispos
} }
} }
/**
* 开始定时执行注册的任务,每十秒去刷新一次
*/
public void startRegisterTask() { public void startRegisterTask() {
if (scheduledTask != null && !scheduledTask.isDone()) { if (scheduledTask != null && !scheduledTask.isDone()) {
return; return;
......
...@@ -40,10 +40,11 @@ public class InstanceRegistry { ...@@ -40,10 +40,11 @@ public class InstanceRegistry {
} }
/** /**
* 注册实例
* Register instance. * Register instance.
* *
* @param registration instance to be registered. * @param registration 实例将会被注册.
* @return the if of the registered instance. * @return 注册之后的ID.
*/ */
public Mono<InstanceId> register(Registration registration) { public Mono<InstanceId> register(Registration registration) {
Assert.notNull(registration, "'registration' must not be null"); Assert.notNull(registration, "'registration' must not be null");
...@@ -94,6 +95,6 @@ public class InstanceRegistry { ...@@ -94,6 +95,6 @@ public class InstanceRegistry {
*/ */
public Mono<InstanceId> deregister(InstanceId id) { public Mono<InstanceId> deregister(InstanceId id) {
return repository.computeIfPresent(id, (key, instance) -> Mono.just(instance.deregister())) return repository.computeIfPresent(id, (key, instance) -> Mono.just(instance.deregister()))
.map(Instance::getId); .map(Instance::getId);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment