Polyglot support with Sidecarhttps://cloud.spring.io/spring-cloud-netflix/reference/html/#_polyglot_support_with_sidecarSidecar异构语言,我们知道在整个微服务系统里面,我们可能不只用JAVA这一种语言,我们可能有一部分微服务使用的是Node,有可能是PHP,那这个时候怎么办呢,我可以使用SideCar异构的微服务,纳入到SpringCloud的生态圈里面来,他的灵感来自Netflix Pranahttps://github.com/Netflix/PranaDo you have non-JVM languages with which you want to take advantage of Eureka, Ribbon, and Config Server? The Spring Cloud Netflix Sidecar was inspired by Netflix Prana. 异构的APP实现健康指示器,然后返回的数据格式应该是这个样子的{"status":"UP"
}那我们先写一个异构的微服务,我需要引入Node的哪些模块,http模块,url模块,path模块

microservice-sidecar应该把sidecar翻译成附加服务,或者叫附加应用,https://www.cnblogs.com/rjzheng/p/10390827.html@EnableSidecar这是一个组合注解/*** @author Spencer Gibb*/
@EnableCircuitBreaker
@EnableDiscoveryClient
@EnableZuulProxy
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import(SidecarConfiguration.class)
public @interface EnableSidecar {}整合了断路器,整合了服务发现,整合了ZuulProxy,注册到Eureka正常写https://cloud.spring.io/spring-cloud-netflix/reference/html/#_polyglot_support_with_sidecar主要的是这一段sidecar:port: 8000health-uri: http://localhost:8000/health.jsonsidecar.port.health-uri=http://localhost:8000/health.json
sidecar.port=8000localhost:8010/sidecarsidecar他其实做了一个桥,他通过异构微服务Node写的health.json,就是健康检查指示器,它会把状态搞到sidecar状态里面去localhost:8070/healthTo enable the Sidecar, create a Spring Boot application with @EnableSidecar. This annotation includes @EnableCircuitBreaker, @EnableDiscoveryClient, and @EnableZuulProxy. Run the resulting application on the same host as the non-JVM application.https://github.com/spring-cloud/spring-cloud-netflix/issues/1505How can I make a polyglot app high available with sidecar #1505sidecar的高可用I have a nodejs microservice called node-service , and now I want to deploy them with two nodes with sidecar. Here goes the IP address:node1: which hostname is node-service1, and port is 8888
node2: which hostname is node-service2, and port is 8888
How to deploy them with sidecar?Is it like this:create two sidecars, one isserver:port: 8060
spring:application:name: sidecar
eureka:client:service-url:defaultZone: http://localhost:8761/eureka/instance:prefer-ip-address: truehostname: node-service1
sidecar:port: 8888                                      health-uri: http://node-service1:8888/health.json
and the other sidecar isserver:port: 8060
spring:application:name: sidecar
eureka:client:service-url:defaultZone: http://localhost:8761/eureka/instance:prefer-ip-address: truehostname: node-service2
sidecar:port: 8888                                      health-uri: http://node-service2:8888/health.json
In this way, I can deploy the two nodejs service nodes.Am I right? If not, is there any better way?That seems fine to me, if there something that is not working as expected?https://my.oschina.net/eacdy/blog/3047330分享:个人是怎么学习新知识的/*** @author Spencer Gibb*/
public class LocalApplicationHealthIndicator extends AbstractHealthIndicator {@Autowiredprivate SidecarProperties properties;@SuppressWarnings("unchecked")@Overrideprotected void doHealthCheck(Health.Builder builder) throws Exception {URI uri = this.properties.getHealthUri();if (uri == null) {builder.up();return;}Map<String, Object> map = new RestTemplate().getForObject(uri, Map.class);Object status = map.get("status");if (status != null && status instanceof String) {builder.status(status.toString());}else if (status != null && status instanceof Map) {Map<String, Object> statusMap = (Map<String, Object>) status;Object code = statusMap.get("code");if (code != null) {builder.status(code.toString());}else {getWarning(builder);}}else {getWarning(builder);}}private Health.Builder getWarning(Health.Builder builder) {return builder.unknown().withDetail("warning", "no status field in response");}}/*** @author Spencer Gibb*/
@RestController
public class SidecarController {@Autowiredprivate DiscoveryClient discovery;@Value("${spring.application.name}")private String appName;@RequestMapping("/ping")public String ping() {return "OK";}@RequestMapping("/hosts/{appName}")public List<ServiceInstance> hosts(@PathVariable("appName") String appName) {return hosts2(appName);}@RequestMapping("/hosts")public List<ServiceInstance> hosts2(@RequestParam("appName") String appName) {List<ServiceInstance> instances = this.discovery.getInstances(appName);return instances;}@RequestMapping(value = "/", produces = "text/html")public String home() {return "<head><title>Sidecar</title></head><body>\n"+ "<a href='/ping'>ping</a><br/>\n"+ "<a href='/health'>health</a><br/>\n" + "<a href='/hosts/"+ this.appName + "'>hosts/" + this.appName + "</a><br/>\n" + "</body>";}}localhost:8070
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.learn.cloud</groupId><artifactId>microservice-sidecar</artifactId><version>0.0.1-SNAPSHOT</version><packaging>jar</packaging><parent><groupId>cn.learn</groupId><artifactId>microcloud02</artifactId><version>0.0.1</version></parent><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-zuul</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-eureka</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-netflix-sidecar</artifactId></dependency></dependencies><!-- 这个插件,可以将应用打包成一个可执行的jar包 --><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>
server.port=8070
spring.application.name=microservice-sidecar
eureka.instance.prefer-ip-address=true
eureka.instance.instance-id=${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}}
eureka.client.serviceUrl.defaultZone=http://admin:1234@10.40.8.152:8761/eureka
eureka.instance.appname=8070
logging.level.com.learn=trace
logging.file=springboot.log
logging.pattern.console=%d{yyyy-MM-dd} [%thread] %-5level %logger{50} - %msg%n
logging.pattern.file=%d{yyyy-MM-dd} ==== [%thread] %-5level ==== %logger{50} ==== %msg%n#management.security.enabled=falsesidecar.port.health-uri=http://localhost:8000/health.json
sidecar.port=8000
package com.learn.cloud;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.sidecar.EnableSidecar;@EnableSidecar
@SpringBootApplication
public class SidecarApplication {public static void main(String[] args) {SpringApplication.run(SidecarApplication.class, args);}
}

使用Sidecar支持异构平台的微服务相关推荐

  1. iUAP云运维平台v3.0全面支持基于K8s的微服务架构

    什么是微服务架构? 微服务(MicroServices)架构是当前互联网业界的一个技术热点,业内各公司也都纷纷开展微服务化体系建设.微服务架构的本质,是用一些功能比较明确.业务比较精练的服务去解决更大 ...

  2. Java生鲜电商平台-SpringCloud微服务开发中的数据架构设计实战精讲

    Java生鲜电商平台-SpringCloud微服务开发中的数据架构设计实战精讲 Java生鲜电商平台:   微服务是当前非常流行的技术框架,通过服务的小型化.原子化以及分布式架构的弹性伸缩和高可用性, ...

  3. Java生鲜电商平台-SpringCloud微服务架构中分布式事务解决方案

    Java生鲜电商平台-SpringCloud微服务架构中分布式事务解决方案 说明:Java生鲜电商平台中由于采用了微服务架构进行业务的处理,买家,卖家,配送,销售,供应商等进行服务化,但是不可避免存在 ...

  4. Java生鲜电商平台-SpringCloud微服务架构高并发参数优化实战

    Java生鲜电商平台-SpringCloud微服务架构高并发参数优化实战 一.写在前面 在Java生鲜电商平台平台中相信不少朋友都在自己公司使用Spring Cloud框架来构建微服务架构,毕竟现在这 ...

  5. Java生鲜电商平台-SpringCloud微服务架构中网络请求性能优化与源码解析

    Java生鲜电商平台-SpringCloud微服务架构中网络请求性能优化与源码解析 说明:Java生鲜电商平台中,由于服务进行了拆分,很多的业务服务导致了请求的网络延迟与性能消耗,对应的这些问题,我们 ...

  6. 公开课|百度天工物联网基础平台的微服务容器化落地实践

    本文整理自中信出版社<物联网时代> 在采用IoT的世界中,改变既是IoT引发的,也是你的生活中无法回避的事实. 弗洛伦斯·赫德森,是Internet2(Internet2,即I2,是指由美 ...

  7. 直播回顾 | BPM平台与微服务架构天生契合(附资料下载)_Nebulogy_纳比云

    <K讲啦第九期直播>干货解读上期回顾 企业微服务架构选型的关键要素:随时.随地.随需.随人.在产品和技术选型中,企业可采用渐进式的建设方法,先专注其中某几个要素,分析业务需求并引入相应的技 ...

  8. 基于srs流媒体服务器搭建gb28181视频平台的微服务系统架构

    gb28181安防视频平台 引言 安防就是视频监控,小区或者办公室装几个摄像头,物业或者保安在监控室盯着大 屏坐一整天. 对于安防架构的理解:摄像头+网络布线+数据存储管理硬盘 (RAID)+媒体软件 ...

  9. 通过API开发平台构建微服务应用实例(一)

    API开发平台能帮助开发人员快速发布API和构建微服务,那么这个过程是怎么样的,我们今天就用使用实际的场景来演示整个开发过程.下图是传统供应链系统的功能架构. 可以看到供应链系统的模块还是比较多的,我 ...

最新文章

  1. 域名解析和cdn 原理
  2. PCL点云数据 滤波降噪
  3. IIS 6.0的web园 最大工作进程数
  4. mysql 输出参数赋值_【Mysql 调用存储过程,输出参数的坑】
  5. c++工程师面试常见问题之c++中四种cast转换
  6. 机器学习的宝典-华校专老师的笔记
  7. pyecharts基础系列总结(含全系列文章路径)
  8. 空类-自动生成的函数
  9. js cookies 存数组_用一个例子理解JS函数的底层处理机制
  10. android listview 切换,Android:在ListView适配器中切换OnCheckedChangeListener
  11. 每个人都该知道的数字
  12. Clay:易塑的c#动态对象——第一部分:为什么我们需要它
  13. 【转】prufer编码
  14. Java虚拟机知识点【方法调用】
  15. linux fdisk运用
  16. 网站换服务器会降权,网站更换IP地址,对SEO有什么影响?
  17. 后盾网-CI框架实例教程-马振宇 - 学习笔记(9)
  18. 阴阳师2017 7服务器维护,《阴阳师》手游4月17日维护更新公告
  19. C. Product 1 Modulo N
  20. centos光盘修复引导_CentOs7 修复 引导启动

热门文章

  1. Windows2003下面的批量创建随机用户程序(.NET多线程)
  2. 记一次特别的往事 while 循环
  3. zabbix—自动发现端口并监控
  4. 阿里云Elasticsearch -- 从0到1的云产品演进之路
  5. shell后台执行命令-crontab
  6. 关于H3C MSR路由器L2TP隧道协议路由配置的特点
  7. css优先级计算规则
  8. Exchange 默认数据库删除问题
  9. int i 引出JVM故事
  10. Java认证授权框架Spring Security介绍