Align with changes to CouchbaseReactiveHealthIndicator
Closes gh-14799
This commit is contained in:
parent
9350ef6921
commit
98d95268e1
|
|
@ -17,7 +17,7 @@ package org.springframework.boot.actuate.autoconfigure.couchbase;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.couchbase.client.java.Bucket;
|
import com.couchbase.client.java.Cluster;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.health.CompositeReactiveHealthIndicatorConfiguration;
|
import org.springframework.boot.actuate.autoconfigure.health.CompositeReactiveHealthIndicatorConfiguration;
|
||||||
|
|
@ -31,10 +31,9 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.autoconfigure.data.couchbase.CouchbaseReactiveDataAutoConfiguration;
|
import org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.data.couchbase.core.RxJavaCouchbaseOperations;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link EnableAutoConfiguration Auto-configuration} for
|
* {@link EnableAutoConfiguration Auto-configuration} for
|
||||||
|
|
@ -45,31 +44,30 @@ import org.springframework.data.couchbase.core.RxJavaCouchbaseOperations;
|
||||||
* @since 2.1.0
|
* @since 2.1.0
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConditionalOnClass({ Bucket.class, RxJavaCouchbaseOperations.class, Flux.class })
|
@ConditionalOnClass({ Cluster.class, Flux.class })
|
||||||
@ConditionalOnBean(RxJavaCouchbaseOperations.class)
|
@ConditionalOnBean(Cluster.class)
|
||||||
@ConditionalOnEnabledHealthIndicator("couchbase")
|
@ConditionalOnEnabledHealthIndicator("couchbase")
|
||||||
@AutoConfigureBefore(HealthIndicatorAutoConfiguration.class)
|
@AutoConfigureBefore(HealthIndicatorAutoConfiguration.class)
|
||||||
@AutoConfigureAfter(CouchbaseReactiveDataAutoConfiguration.class)
|
@AutoConfigureAfter(CouchbaseAutoConfiguration.class)
|
||||||
public class CouchbaseReactiveHealthIndicatorAutoConfiguration extends
|
public class CouchbaseReactiveHealthIndicatorAutoConfiguration extends
|
||||||
CompositeReactiveHealthIndicatorConfiguration<CouchbaseReactiveHealthIndicator, RxJavaCouchbaseOperations> {
|
CompositeReactiveHealthIndicatorConfiguration<CouchbaseReactiveHealthIndicator, Cluster> {
|
||||||
|
|
||||||
private final Map<String, RxJavaCouchbaseOperations> couchbaseOperations;
|
private final Map<String, Cluster> clusters;
|
||||||
|
|
||||||
public CouchbaseReactiveHealthIndicatorAutoConfiguration(
|
public CouchbaseReactiveHealthIndicatorAutoConfiguration(
|
||||||
Map<String, RxJavaCouchbaseOperations> couchbaseOperations) {
|
Map<String, Cluster> clusters) {
|
||||||
this.couchbaseOperations = couchbaseOperations;
|
this.clusters = clusters;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean(name = "couchbaseReactiveHealthIndicator")
|
@ConditionalOnMissingBean(name = "couchbaseReactiveHealthIndicator")
|
||||||
public ReactiveHealthIndicator couchbaseReactiveHealthIndicator() {
|
public ReactiveHealthIndicator couchbaseReactiveHealthIndicator() {
|
||||||
return createHealthIndicator(this.couchbaseOperations);
|
return createHealthIndicator(this.clusters);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CouchbaseReactiveHealthIndicator createHealthIndicator(
|
protected CouchbaseReactiveHealthIndicator createHealthIndicator(Cluster cluster) {
|
||||||
RxJavaCouchbaseOperations couchbaseOperations) {
|
return new CouchbaseReactiveHealthIndicator(cluster);
|
||||||
return new CouchbaseReactiveHealthIndicator(couchbaseOperations);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package org.springframework.boot.actuate.autoconfigure.couchbase;
|
package org.springframework.boot.actuate.autoconfigure.couchbase;
|
||||||
|
|
||||||
|
import com.couchbase.client.java.Cluster;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration;
|
import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration;
|
||||||
|
|
@ -25,7 +26,6 @@ import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.data.couchbase.core.RxJavaCouchbaseOperations;
|
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
@ -63,8 +63,8 @@ public class CouchbaseReactiveHealthIndicatorAutoConfigurationTests {
|
||||||
protected static class CouchbaseMockConfiguration {
|
protected static class CouchbaseMockConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public RxJavaCouchbaseOperations couchbaseOperations() {
|
public Cluster couchbaseCluster() {
|
||||||
return mock(RxJavaCouchbaseOperations.class);
|
return mock(Cluster.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue