use of com.ecwid.consul.v1.health.model.HealthService.Service in project spring-cloud-consul by spring-cloud.
the class ConsulServiceRegistryDisabledTests method testAutoRegistrationDisabled.
private void testAutoRegistrationDisabled(String testName, String disableProperty) {
new WebApplicationContextRunner().withUserConfiguration(TestConfig.class).withPropertyValues("spring.application.name=" + testName, disableProperty + "=false", "server.port=0").withInitializer(new ConsulTestcontainers()).run(context -> {
assertThat(context).doesNotHaveBean(ConsulServiceRegistry.class);
assertThat(context).doesNotHaveBean(HeartbeatProperties.class);
ConsulClient consul = context.getBean(ConsulClient.class);
Response<Map<String, Service>> response = consul.getAgentServices();
Map<String, Service> services = response.getValue();
Service service = services.get(testName);
assertThat(service).as("service was registered").isNull();
});
}
use of com.ecwid.consul.v1.health.model.HealthService.Service in project spring-cloud-consul by spring-cloud.
the class ConsulServiceRegistry method getStatus.
@Override
public Object getStatus(ConsulRegistration registration) {
String serviceId = registration.getServiceId();
Response<List<Check>> response = this.client.getHealthChecksForService(serviceId, HealthChecksForServiceRequest.newBuilder().setQueryParams(QueryParams.DEFAULT).build());
List<Check> checks = response.getValue();
for (Check check : checks) {
if (check.getServiceId().equals(registration.getInstanceId())) {
if (check.getName().equalsIgnoreCase("Service Maintenance Mode")) {
return OUT_OF_SERVICE.getCode();
}
}
}
return UP.getCode();
}
Aggregations