org.springframework.cloud.consul.serviceregistry.ConsulRegistration Java Examples
The following examples show how to use
org.springframework.cloud.consul.serviceregistry.ConsulRegistration.
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: ServiceDefinitionToConsulRegistration.java From camel-spring-boot with Apache License 2.0 | 7 votes |
@Override public ConsulRegistration convert(ServiceDefinition source) { NewService service = new NewService(); service.setName(source.getName()); service.setId(source.getId()); service.setAddress(properties.getServiceRegistry().getServiceHost()); service.setPort(source.getPort()); service.setTags( source.getMetadata().entrySet().stream() .map(e -> e.getKey() + "=" + e.getValue()) .collect(Collectors.toList()) ); return new ConsulRegistration(service, null) { @Override public boolean isSecure() { return service.getPort() == 443 || Objects.equals("https", source.getMetadata().get(ServiceDefinition.SERVICE_META_PROTOCOL)); } }; }
Example #2
Source File: DubboServiceRegistrationAutoConfiguration.java From spring-cloud-alibaba with Apache License 2.0 | 6 votes |
private void attachURLsIntoMetadata(ConsulRegistration consulRegistration) { NewService newService = consulRegistration.getService(); Map<String, String> serviceMetadata = dubboServiceMetadataRepository .getDubboMetadataServiceMetadata(); if (!isEmpty(serviceMetadata)) { List<String> tags = newService.getTags(); for (Map.Entry<String, String> entry : serviceMetadata.entrySet()) { tags.add(entry.getKey() + "=" + entry.getValue()); } } }
Example #3
Source File: GrpcConsulRegistrar.java From grpc-spring-boot-starter with Apache License 2.0 | 6 votes |
private ConsulRegistration getRegistration(GRpcServerInitializedEvent event) { ApplicationContext applicationContext = event.getApplicationContext(); ConsulDiscoveryProperties consulProperties = applicationContext.getBean(ConsulDiscoveryProperties.class); GRpcServerProperties gRpcServerProperties = event.getApplicationContext().getBean(GRpcServerProperties.class); NewService grpcService = new NewService(); grpcService.setPort(event.getServer().getPort()); if (!consulProperties.isPreferAgentAddress()) { grpcService.setAddress(consulProperties.getHostname()); } String appName = "grpc-" + ConsulAutoRegistration.getAppName(consulProperties, applicationContext.getEnvironment()); grpcService.setName(ConsulAutoRegistration.normalizeForDns(appName)); grpcService.setId("grpc-" + ConsulAutoRegistration.getInstanceId(consulProperties, applicationContext)); grpcService.setTags(ConsulAutoRegistration.createTags(consulProperties) .stream() .filter(t->!t.startsWith("secure=")) .collect(Collectors.toList()) ); if(consulProperties.isRegisterHealthCheck()) { GRpcConsulHealthCheck health = GRpcConsulHealthCheck.builder() .socketAddr(consulProperties.getHostname() + ":" + event.getServer().getPort()) .grpcUseTlc(Objects.nonNull(gRpcServerProperties.getSecurity())) .interval(consulProperties.getHealthCheckInterval()) .timeout(consulProperties.getHealthCheckTimeout()) .build(); health.setDeregisterCriticalServiceAfter(consulProperties.getHealthCheckCriticalTimeout()); grpcService.setCheck(health); } return new ConsulRegistration(grpcService, consulProperties); }
Example #4
Source File: LoggingConfiguration.java From cubeai with Apache License 2.0 | 5 votes |
public LoggingConfiguration(@Value("${spring.application.name}") String appName, @Value("${server.port}") String serverPort, ConsulRegistration consulRegistration, @Value("${info.project.version}") String version, JHipsterProperties jHipsterProperties) { this.appName = appName; this.serverPort = serverPort; this.consulRegistration = consulRegistration; this.version = version; this.jHipsterProperties = jHipsterProperties; if (jHipsterProperties.getLogging().getLogstash().isEnabled()) { addLogstashAppender(context); addContextListener(context); } if (jHipsterProperties.getMetrics().getLogs().isEnabled()) { setMetricsMarkerLogbackFilter(context); } }
Example #5
Source File: LoggingConfiguration.java From cubeai with Apache License 2.0 | 5 votes |
public LoggingConfiguration(@Value("${spring.application.name}") String appName, @Value("${server.port}") String serverPort, ConsulRegistration consulRegistration, @Value("${info.project.version}") String version, JHipsterProperties jHipsterProperties) { this.appName = appName; this.serverPort = serverPort; this.consulRegistration = consulRegistration; this.version = version; this.jHipsterProperties = jHipsterProperties; if (jHipsterProperties.getLogging().getLogstash().isEnabled()) { addLogstashAppender(context); addContextListener(context); } if (jHipsterProperties.getMetrics().getLogs().isEnabled()) { setMetricsMarkerLogbackFilter(context); } }
Example #6
Source File: LoggingConfiguration.java From cubeai with Apache License 2.0 | 5 votes |
public LoggingConfiguration(@Value("${spring.application.name}") String appName, @Value("${server.port}") String serverPort, ConsulRegistration consulRegistration, @Value("${info.project.version}") String version, JHipsterProperties jHipsterProperties) { this.appName = appName; this.serverPort = serverPort; this.consulRegistration = consulRegistration; this.version = version; this.jHipsterProperties = jHipsterProperties; if (jHipsterProperties.getLogging().getLogstash().isEnabled()) { addLogstashAppender(context); addContextListener(context); } if (jHipsterProperties.getMetrics().getLogs().isEnabled()) { setMetricsMarkerLogbackFilter(context); } }
Example #7
Source File: LoggingConfiguration.java From cubeai with Apache License 2.0 | 5 votes |
public LoggingConfiguration(@Value("${spring.application.name}") String appName, @Value("${server.port}") String serverPort, ConsulRegistration consulRegistration, @Value("${info.project.version}") String version, JHipsterProperties jHipsterProperties) { this.appName = appName; this.serverPort = serverPort; this.consulRegistration = consulRegistration; this.version = version; this.jHipsterProperties = jHipsterProperties; if (jHipsterProperties.getLogging().getLogstash().isEnabled()) { addLogstashAppender(context); addContextListener(context); } if (jHipsterProperties.getMetrics().getLogs().isEnabled()) { setMetricsMarkerLogbackFilter(context); } }
Example #8
Source File: LoggingConfiguration.java From cubeai with Apache License 2.0 | 5 votes |
public LoggingConfiguration(@Value("${spring.application.name}") String appName, @Value("${server.port}") String serverPort, ConsulRegistration consulRegistration, @Value("${info.project.version}") String version, JHipsterProperties jHipsterProperties) { this.appName = appName; this.serverPort = serverPort; this.consulRegistration = consulRegistration; this.version = version; this.jHipsterProperties = jHipsterProperties; if (jHipsterProperties.getLogging().getLogstash().isEnabled()) { addLogstashAppender(context); addContextListener(context); } if (jHipsterProperties.getMetrics().getLogs().isEnabled()) { setMetricsMarkerLogbackFilter(context); } }
Example #9
Source File: LoggingConfiguration.java From cubeai with Apache License 2.0 | 5 votes |
public LoggingConfiguration(@Value("${spring.application.name}") String appName, @Value("${server.port}") String serverPort, ConsulRegistration consulRegistration, @Value("${info.project.version}") String version, JHipsterProperties jHipsterProperties) { this.appName = appName; this.serverPort = serverPort; this.consulRegistration = consulRegistration; this.version = version; this.jHipsterProperties = jHipsterProperties; if (jHipsterProperties.getLogging().getLogstash().isEnabled()) { addLogstashAppender(context); addContextListener(context); } if (jHipsterProperties.getMetrics().getLogs().isEnabled()) { setMetricsMarkerLogbackFilter(context); } }
Example #10
Source File: LoggingConfiguration.java From cubeai with Apache License 2.0 | 5 votes |
public LoggingConfiguration(@Value("${spring.application.name}") String appName, @Value("${server.port}") String serverPort, ConsulRegistration consulRegistration, @Value("${info.project.version}") String version, JHipsterProperties jHipsterProperties) { this.appName = appName; this.serverPort = serverPort; this.consulRegistration = consulRegistration; this.version = version; this.jHipsterProperties = jHipsterProperties; if (jHipsterProperties.getLogging().getLogstash().isEnabled()) { addLogstashAppender(context); addContextListener(context); } if (jHipsterProperties.getMetrics().getLogs().isEnabled()) { setMetricsMarkerLogbackFilter(context); } }
Example #11
Source File: LoggingConfiguration.java From cubeai with Apache License 2.0 | 5 votes |
public LoggingConfiguration(@Value("${spring.application.name}") String appName, @Value("${server.port}") String serverPort, ConsulRegistration consulRegistration, @Value("${info.project.version}") String version, JHipsterProperties jHipsterProperties) { this.appName = appName; this.serverPort = serverPort; this.consulRegistration = consulRegistration; this.version = version; this.jHipsterProperties = jHipsterProperties; if (jHipsterProperties.getLogging().getLogstash().isEnabled()) { addLogstashAppender(context); addContextListener(context); } if (jHipsterProperties.getMetrics().getLogs().isEnabled()) { setMetricsMarkerLogbackFilter(context); } }
Example #12
Source File: DubboServiceRegistrationAutoConfiguration.java From spring-cloud-alibaba with Apache License 2.0 | 5 votes |
/** * Handle the pre-registered event of {@link ServiceInstance} for Consul. * @param event {@link ServiceInstancePreRegisteredEvent} */ @EventListener(ServiceInstancePreRegisteredEvent.class) public void onServiceInstancePreRegistered( ServiceInstancePreRegisteredEvent event) { Registration registration = event.getSource(); Class<?> registrationClass = AopUtils.getTargetClass(registration); String registrationClassName = registrationClass.getName(); if (CONSUL_AUTO_SERVICE_AUTO_REGISTRATION_CLASS_NAME .equalsIgnoreCase(registrationClassName)) { ConsulRegistration consulRegistration = (ConsulRegistration) registration; attachURLsIntoMetadata(consulRegistration); } }
Example #13
Source File: ConsulGrpcRegistrationCustomizer.java From grpc-spring-boot-starter with MIT License | 5 votes |
@Override public void customize(final ConsulRegistration registration) { List<String> tags = registration.getService().getTags(); if (tags == null) { tags = new ArrayList<>(); } final int port = this.grpcServerProperties.getPort(); if (port != -1) { tags.add(GrpcUtils.CLOUD_DISCOVERY_METADATA_PORT + "=" + port); registration.getService().setTags(tags); } }
Example #14
Source File: ConsulGrpcRegistrationCustomizer.java From grpc-spring-boot-starter with MIT License | 5 votes |
@Override public void customize(final ConsulRegistration registration) { List<String> tags = registration.getService().getTags(); if (tags == null) { tags = new ArrayList<>(); } final int port = this.grpcServerProperties.getPort(); if (port != -1) { tags.add(GrpcUtils.CLOUD_DISCOVERY_METADATA_PORT + "=" + port); registration.getService().setTags(tags); } }
Example #15
Source File: ServiceDefinitionToConsulRegistrationAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 4 votes |
@Bean(name = "service-definition-to-consul-registration") public Converter<ServiceDefinition, ConsulRegistration> serviceDefinitionToConsulRegistration( CamelCloudConfigurationProperties properties) { return new ServiceDefinitionToConsulRegistration(properties); }