use of com.ecwid.consul.v1.agent.model.NewService in project spring-cloud-consul by spring-cloud.
the class ConsulAutoRegistration method lifecycleRegistration.
// TODO: do I need this here, or should I just copy what I need back into lifecycle?
@Deprecated
public static ConsulAutoRegistration lifecycleRegistration(Integer port, String instanceId, AutoServiceRegistrationProperties autoServiceRegistrationProperties, ConsulDiscoveryProperties properties, ApplicationContext context, List<ConsulRegistrationCustomizer> registrationCustomizers, HeartbeatProperties heartbeatProperties) {
NewService service = new NewService();
String appName = getAppName(properties, context.getEnvironment());
service.setId(instanceId);
if (!properties.isPreferAgentAddress()) {
service.setAddress(properties.getHostname());
}
service.setName(normalizeForDns(appName));
service.setTags(createTags(properties));
// If an alternate external port is specified, register using it instead
if (properties.getPort() != null) {
service.setPort(properties.getPort());
} else {
service.setPort(port);
}
Assert.notNull(service.getPort(), "service.port may not be null");
setCheck(service, autoServiceRegistrationProperties, properties, context, heartbeatProperties);
ConsulAutoRegistration registration = new ConsulAutoRegistration(service, autoServiceRegistrationProperties, properties, context, heartbeatProperties);
customize(registrationCustomizers, registration);
return registration;
}
use of com.ecwid.consul.v1.agent.model.NewService in project spring-cloud-consul by spring-cloud.
the class ConsulAutoServiceRegistrationCustomizedDiscoveryPortTests method contextLoads.
@Test
public void contextLoads() {
NewService service = this.registration.getService();
assertThat(service).as("service was null").isNotNull();
assertThat(service.getPort()).as("service port is 0").isGreaterThan(0);
NewService.Check check = service.getCheck();
assertThat(check).as("check was null").isNotNull();
String httpCheck = String.format("%s://%s:%s%s", properties.getScheme(), properties.getHostname(), properties.getPort(), properties.getHealthCheckPath());
assertThat(check.getHttp()).as("http check was wrong").isEqualTo(httpCheck);
// unable to call consul api to get health check details
}
Aggregations