spring-cloud / spring-cloud-consul

Spring Cloud Consul
http://cloud.spring.io/spring-cloud-consul/
Apache License 2.0
813 stars 541 forks source link

ConfigWatch requires spring-boot-actuator #274

Open msvab opened 7 years ago

msvab commented 7 years ago

Hi,

I'm using consul config in a spring application that doesn't have a web server. So I didn't include spring-boot-actuator, since I didn't see the need for it. However in ConsulConfigAutoConfiguration the ConfigWatch is enabled only when RefreshEndpoint from actuator is available.

If I put the following into my app, ConfigWatch works as expected without the actuator dependency.

@EnableScheduling
public class App extends SpringApplication {

    @Bean
    public ConfigWatch configWatch(ConsulConfigProperties properties, ConsulPropertySourceLocator locator, ConsulClient consul) {
        return new ConfigWatch(properties, locator.getContexts(), consul);
    }
}

Actuator enables scheduling automatically in MetricExportAutoConfiguration and so it would have to be enabled in ConsulConfigAutoConfiguration. I don't think there would be any side-effects from this change.

Cheers, Michal

spencergibb commented 7 years ago

So the ConfigWatch may not require actuator, but the RefreshEventListener does require it.

msvab commented 7 years ago

You're right, I've missed that! The RefreshEventListener calls RefreshEndpoint only to call ContextRefresher.refresh(). Would it be possible to inject ContextRefresher directly into RefreshEventListener instead of RefreshEndpoint?

spencergibb commented 7 years ago

Of course, anything is possible, but I'd rather not introduce that coupling. The right thing to do is install the RefreshEventListener regardless of if actuator is present.

Depends on https://github.com/spring-cloud/spring-cloud-commons/issues/171

msvab commented 7 years ago

Alright, sounds good to me. Thanks!