Go Chassis接入CSE的ServiceComb引擎
本章节介绍Go Chassis如何接入CSE的ServiceComb引擎,使得Go Chassis能够对接CSE的ServiceComb引擎,并且方便的使用CSE提供的最常用的功能。在使用ServiceComb引擎功能章节,会给出具体的开发指导。
本章节介绍的开发方法,可以在Go Chassis Sample Discovery项目中找到对应的代码,供您在开发过程中参考。
前提条件
- 已基于Go Chassis开发好了微服务应用。
Go Chassis微服务框架下的微服务应用开发,请参考https://go-chassis.readthedocs.io/en/latest/。
- 相关软件版本要求:Golang 1.16及以上版本。
操作步骤
- 在项目的“go.mod”文件中引入依赖。
请在您的项目的“go.mod”中添加以下依赖。如果您的项目中已经包含以下依赖,则不需要做任何处理。
github.com/go-chassis/go-chassis/v2 v2.3.0
- 设置注册中心和配置中心。
在“chassis.yaml”文件中增加配置项:
servicecomb: registry: type: servicecenter #无需设置,默认为servicecenter address: 服务注册发现地址 config: client: type: {servertype} serverUri: 配置中心地址
- 当ServiceComb引擎版本为1.x时,{servertype}取值为config-center。
- 当ServiceComb引擎版本为2.x时,{servertype}取值为kie。