org.springframework.cloud.consul.discovery.HeartbeatProperties Java Examples
The following examples show how to use
org.springframework.cloud.consul.discovery.HeartbeatProperties.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConsulAutoRegistration.java From spring-cloud-consul with Apache License 2.0 | 7 votes |
public static void setCheck(NewService service, AutoServiceRegistrationProperties autoServiceRegistrationProperties, ConsulDiscoveryProperties properties, ApplicationContext context, HeartbeatProperties heartbeatProperties) { if (properties.isRegisterHealthCheck() && service.getCheck() == null) { Integer checkPort; if (shouldRegisterManagement(autoServiceRegistrationProperties, properties, context)) { checkPort = getManagementPort(properties, context); } else { checkPort = service.getPort(); } Assert.notNull(checkPort, "checkPort may not be null"); service.setCheck(createCheck(checkPort, heartbeatProperties, properties)); } }
Example #2
Source File: ConsulAutoRegistration.java From spring-cloud-consul with Apache License 2.0 | 7 votes |
public static ConsulAutoRegistration managementRegistration( AutoServiceRegistrationProperties autoServiceRegistrationProperties, ConsulDiscoveryProperties properties, ApplicationContext context, List<ConsulManagementRegistrationCustomizer> managementRegistrationCustomizers, HeartbeatProperties heartbeatProperties) { NewService management = new NewService(); management.setId(getManagementServiceId(properties, context)); management.setAddress(properties.getHostname()); management .setName(getManagementServiceName(properties, context.getEnvironment())); management.setPort(getManagementPort(properties, context)); management.setTags(properties.getManagementTags()); management.setEnableTagOverride(properties.getManagementEnableTagOverride()); management.setMeta(properties.getManagementMetadata()); if (properties.isRegisterHealthCheck()) { management.setCheck(createCheck(getManagementPort(properties, context), heartbeatProperties, properties)); } ConsulAutoRegistration registration = new ConsulAutoRegistration(management, autoServiceRegistrationProperties, properties, context, heartbeatProperties, managementRegistrationCustomizers); managementCustomize(managementRegistrationCustomizers, registration); return registration; }
Example #3
Source File: SidecarConsulAutoRegistration.java From spring-cloud-alibaba with Apache License 2.0 | 6 votes |
public SidecarConsulAutoRegistration(NewService service, AutoServiceRegistrationProperties autoServiceRegistrationProperties, ConsulDiscoveryProperties properties, ApplicationContext context, HeartbeatProperties heartbeatProperties, List<ConsulManagementRegistrationCustomizer> managementRegistrationCustomizers) { super(service, autoServiceRegistrationProperties, properties, context, heartbeatProperties, managementRegistrationCustomizers); }
Example #4
Source File: ConsulLightminClientDiscoveryConfiguration.java From spring-batch-lightmin with Apache License 2.0 | 6 votes |
@Bean @ConditionalOnMissingBean(ConsulAutoRegistration.class) public ConsulAutoRegistration consulAutoRegistration( final MetaDataExtender metaDataExtender, final AutoServiceRegistrationProperties autoServiceRegistrationProperties, final ConsulDiscoveryProperties consulDiscoveryProperties, final ApplicationContext applicationContext, final List<ConsulRegistrationCustomizer> consulRegistrationCustomizers, final List<ConsulManagementRegistrationCustomizer> managementRegistrationCustomizers, final HeartbeatProperties heartbeatProperties) { metaDataExtender.extendMetaData(); return ConsulAutoRegistration.registration( autoServiceRegistrationProperties, consulDiscoveryProperties, applicationContext, consulRegistrationCustomizers, managementRegistrationCustomizers, heartbeatProperties); }
Example #5
Source File: ConsulAutoRegistration.java From spring-cloud-consul with Apache License 2.0 | 6 votes |
@Deprecated public ConsulAutoRegistration(NewService service, AutoServiceRegistrationProperties autoServiceRegistrationProperties, ConsulDiscoveryProperties properties, ApplicationContext context, HeartbeatProperties heartbeatProperties) { this(service, autoServiceRegistrationProperties, properties, context, heartbeatProperties, Collections.emptyList()); }
Example #6
Source File: ConsulAutoRegistration.java From spring-cloud-consul with Apache License 2.0 | 6 votes |
public ConsulAutoRegistration(NewService service, AutoServiceRegistrationProperties autoServiceRegistrationProperties, ConsulDiscoveryProperties properties, ApplicationContext context, HeartbeatProperties heartbeatProperties, List<ConsulManagementRegistrationCustomizer> managementRegistrationCustomizers) { super(service, properties); this.autoServiceRegistrationProperties = autoServiceRegistrationProperties; this.context = context; this.heartbeatProperties = heartbeatProperties; this.managementRegistrationCustomizers = managementRegistrationCustomizers; }
Example #7
Source File: ConsulAutoRegistration.java From spring-cloud-consul with Apache License 2.0 | 6 votes |
public static NewService.Check createCheck(Integer port, HeartbeatProperties ttlConfig, ConsulDiscoveryProperties properties) { NewService.Check check = new NewService.Check(); if (StringUtils.hasText(properties.getHealthCheckCriticalTimeout())) { check.setDeregisterCriticalServiceAfter( properties.getHealthCheckCriticalTimeout()); } if (ttlConfig.isEnabled()) { // FIXME 3.0.0 // https://github.com/spring-cloud/spring-cloud-consul/issues/614 check.setTtl(ttlConfig.getTtl().getSeconds() + "s"); return check; } Assert.notNull(port, "createCheck port must not be null"); Assert.isTrue(port > 0, "createCheck port must be greater than 0"); 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.setHeader(properties.getHealthCheckHeaders()); check.setInterval(properties.getHealthCheckInterval()); check.setTimeout(properties.getHealthCheckTimeout()); check.setTlsSkipVerify(properties.getHealthCheckTlsSkipVerify()); return check; }
Example #8
Source File: ConsulServiceRegistryDisabledTests.java From spring-cloud-consul with Apache License 2.0 | 6 votes |
private void testAutoRegistrationDisabled(String testName, String disableProperty) { new WebApplicationContextRunner().withUserConfiguration(TestConfig.class) .withPropertyValues("spring.application.name=" + testName, disableProperty + "=false", "server.port=0") .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(); }); }
Example #9
Source File: SidecarConsulAutoConfiguration.java From spring-cloud-alibaba with Apache License 2.0 | 5 votes |
@Bean public ConsulAutoRegistration consulRegistration( AutoServiceRegistrationProperties autoServiceRegistrationProperties, ConsulDiscoveryProperties properties, ApplicationContext applicationContext, ObjectProvider<List<ConsulRegistrationCustomizer>> registrationCustomizers, ObjectProvider<List<ConsulManagementRegistrationCustomizer>> managementRegistrationCustomizers, HeartbeatProperties heartbeatProperties, SidecarProperties sidecarProperties) { return SidecarConsulAutoRegistration.registration( autoServiceRegistrationProperties, properties, applicationContext, registrationCustomizers.getIfAvailable(), managementRegistrationCustomizers.getIfAvailable(), heartbeatProperties, sidecarProperties); }
Example #10
Source File: ConsulServiceRegistry.java From spring-cloud-consul with Apache License 2.0 | 5 votes |
public ConsulServiceRegistry(ConsulClient client, ConsulDiscoveryProperties properties, TtlScheduler ttlScheduler, HeartbeatProperties heartbeatProperties) { this.client = client; this.properties = properties; this.ttlScheduler = ttlScheduler; this.heartbeatProperties = heartbeatProperties; }
Example #11
Source File: ConsulServiceRegistryAutoConfiguration.java From spring-cloud-consul with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean public ConsulServiceRegistry consulServiceRegistry(ConsulClient consulClient, ConsulDiscoveryProperties properties, HeartbeatProperties heartbeatProperties, @Autowired(required = false) TtlScheduler ttlScheduler) { return new ConsulServiceRegistry(consulClient, properties, ttlScheduler, heartbeatProperties); }
Example #12
Source File: ConsulAutoServiceRegistrationAutoConfiguration.java From spring-cloud-consul with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean public ConsulAutoRegistration consulRegistration( AutoServiceRegistrationProperties autoServiceRegistrationProperties, ConsulDiscoveryProperties properties, ApplicationContext applicationContext, ObjectProvider<List<ConsulRegistrationCustomizer>> registrationCustomizers, ObjectProvider<List<ConsulManagementRegistrationCustomizer>> managementRegistrationCustomizers, HeartbeatProperties heartbeatProperties) { return ConsulAutoRegistration.registration(autoServiceRegistrationProperties, properties, applicationContext, registrationCustomizers.getIfAvailable(), managementRegistrationCustomizers.getIfAvailable(), heartbeatProperties); }
Example #13
Source File: ConsulServiceRegistryAutoConfiguration.java From spring-cloud-consul with Apache License 2.0 | 4 votes |
@Bean @ConditionalOnMissingBean public HeartbeatProperties heartbeatProperties() { return new HeartbeatProperties(); }
Example #14
Source File: ConsulHeartbeatAutoConfiguration.java From spring-cloud-consul with Apache License 2.0 | 4 votes |
@Bean @ConditionalOnMissingBean public HeartbeatProperties heartbeatProperties() { return new HeartbeatProperties(); }
Example #15
Source File: ConsulHeartbeatAutoConfiguration.java From spring-cloud-consul with Apache License 2.0 | 4 votes |
@Bean @ConditionalOnMissingBean public TtlScheduler ttlScheduler(HeartbeatProperties heartbeatProperties, ConsulClient consulClient) { return new TtlScheduler(heartbeatProperties, consulClient); }