add lifecycle properties for making service registration optional
This commit is contained in:
@@ -55,6 +55,11 @@ public class ConsulDiscoveryClientConfiguration {
|
||||
return new HeartbeatProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public LifecycleProperties lifecycleProperties() {
|
||||
return new LifecycleProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ConsulDiscoveryProperties consulDiscoveryProperties() {
|
||||
return new ConsulDiscoveryProperties();
|
||||
|
||||
@@ -45,6 +45,9 @@ public class ConsulLifecycle extends AbstractDiscoveryLifecycle {
|
||||
@Autowired
|
||||
private ConsulDiscoveryProperties properties;
|
||||
|
||||
@Autowired
|
||||
private LifecycleProperties lifecycleProperties;
|
||||
|
||||
@Autowired(required = false)
|
||||
private TtlScheduler ttlScheduler;
|
||||
|
||||
@@ -170,7 +173,7 @@ public class ConsulLifecycle extends AbstractDiscoveryLifecycle {
|
||||
|
||||
@Override
|
||||
protected boolean isEnabled() {
|
||||
return properties.isEnabled();
|
||||
return lifecycleProperties.isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.springframework.cloud.consul.discovery;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* @author Aleksandr Tarasov (aatarasoff)
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "spring.cloud.consul.discovery.lifecycle")
|
||||
@Data
|
||||
public class LifecycleProperties {
|
||||
private boolean enabled = true;
|
||||
}
|
||||
Reference in New Issue
Block a user