Switch to taking order from CloudFoundryDiscoveryProperties.
This commit is contained in:
@@ -42,16 +42,16 @@ public class CloudFoundryDiscoveryClient implements DiscoveryClient {
|
||||
|
||||
private final CloudFoundryService cloudFoundryService;
|
||||
private final CloudFoundryOperations cloudFoundryOperations;
|
||||
private final CloudFoundryDiscoveryClientProperties discoveryClientProperties;
|
||||
private final CloudFoundryDiscoveryProperties cloudFoundryDiscoveryProperties;
|
||||
|
||||
private final String description = "Cloud Foundry " + DiscoveryClient.class.getName() + " implementation";
|
||||
|
||||
CloudFoundryDiscoveryClient(CloudFoundryOperations cloudFoundryOperations,
|
||||
CloudFoundryService svc,
|
||||
CloudFoundryDiscoveryClientProperties discoveryClientProperties) {
|
||||
CloudFoundryDiscoveryProperties cloudFoundryDiscoveryProperties) {
|
||||
this.cloudFoundryService = svc;
|
||||
this.cloudFoundryOperations = cloudFoundryOperations;
|
||||
this.discoveryClientProperties = discoveryClientProperties;
|
||||
this.cloudFoundryDiscoveryProperties = cloudFoundryDiscoveryProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,6 +97,6 @@ public class CloudFoundryDiscoveryClient implements DiscoveryClient {
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return this.discoveryClientProperties.getOrder();
|
||||
return this.cloudFoundryDiscoveryProperties.getOrder();
|
||||
}
|
||||
}
|
||||
@@ -34,17 +34,12 @@ import org.springframework.context.annotation.Configuration;
|
||||
@EnableConfigurationProperties(CloudFoundryDiscoveryProperties.class)
|
||||
public class CloudFoundryDiscoveryClientConfiguration {
|
||||
|
||||
@Bean
|
||||
public CloudFoundryDiscoveryClientProperties cloudFoundryDiscoveryClientProperties() {
|
||||
return new CloudFoundryDiscoveryClientProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(CloudFoundryDiscoveryClient.class)
|
||||
public CloudFoundryDiscoveryClient cloudFoundryDiscoveryClient(
|
||||
CloudFoundryOperations cf, CloudFoundryService svc,
|
||||
CloudFoundryDiscoveryClientProperties discoveryClientProperties) {
|
||||
return new CloudFoundryDiscoveryClient(cf, svc, discoveryClientProperties);
|
||||
CloudFoundryDiscoveryProperties cloudFoundryDiscoveryProperties) {
|
||||
return new CloudFoundryDiscoveryClient(cf, svc, cloudFoundryDiscoveryProperties);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -40,6 +40,11 @@ public class CloudFoundryDiscoveryProperties {
|
||||
*/
|
||||
private int defaultServerPort = 80;
|
||||
|
||||
/**
|
||||
* Order of the discovery client used by `CompositeDiscoveryClient` for sorting available clients.
|
||||
*/
|
||||
private int order = 0;
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
@@ -64,12 +69,21 @@ public class CloudFoundryDiscoveryProperties {
|
||||
this.defaultServerPort = defaultServerPort;
|
||||
}
|
||||
|
||||
public int getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public void setOrder(int order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CloudFoundryDiscoveryProperties{" +
|
||||
"enabled=" + enabled +
|
||||
", heartbeatFrequency=" + heartbeatFrequency +
|
||||
", defaultServerPort=" + defaultServerPort +
|
||||
", order=" + order +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class CloudFoundryDiscoveryClientTest {
|
||||
this.ops = mock(CloudFoundryOperations.class);
|
||||
this.svc = mock(CloudFoundryService.class);
|
||||
this.cloudFoundryDiscoveryClient = new CloudFoundryDiscoveryClient(this.ops, this.svc,
|
||||
new CloudFoundryDiscoveryClientProperties());
|
||||
new CloudFoundryDiscoveryProperties());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user