protected void register(NewService newService) { log.info("Registering service with consul: {}", newService.toString()); if (properties.getAclToken() == null) { client.agentServiceRegister(newService); } else { client.agentServiceRegister(newService, properties.getAclToken()); } if (ttlConfig.isEnabled() && ttlScheduler != null) { ttlScheduler.add(newService); } }
private NewService.Check createCheck(Integer port) { NewService.Check check = new NewService.Check(); if (ttlConfig.isEnabled()) { check.setTtl(ttlConfig.getTtl()); return check; } if (properties.getHealthCheckUrl() != null) { check.setHttp(properties.getHealthCheckUrl()); } else { check.setHttp( String.format( "%s://%s:%s%s", properties.getScheme(), properties.getHostname(), port, properties.getHealthCheckPath())); } check.setInterval(properties.getHealthCheckInterval()); // TODO support http check timeout return check; }