- 微服务为什么引入服务注册发现
- 服务注册中心设计原理
- Golang 代码实现服务注册中心
- 服务构建
cd cmd
go build -o discovery main.go
./discovery -c configs.yaml
- 服务注册
curl -XPOST http://127.0.0.1:6666/api/register -H 'Content-Type:application/json' -d'{"env":"dev", "appid":"testapp","hostname":"testhost1","addrs":["rpc:aaa","rpc:bbb"],"status":1,"replication":true}'
- 服务发现
curl -XPOST http://127.0.0.1:6666/api/fetch -H 'Content-Type:application/json' -d'{"env":"dev", "appid":"testapp","status":1}'
curl -XPOST http://127.0.0.1:6666/api/fetchall
- 服务续约
curl -XPOST http://127.0.0.1:8866/api/renew -H 'Content-Type:application/json' -d'{"env":"dev","appid":"testapp","hostname":"testhost","replication":true}'
- 服务取消
curl -XPOST http://127.0.0.1:8866/api/cancel -H 'Content-Type:application/json' -d'{"env":"dev","appid":"testapp","hostname":"testhost","replication":true}'
扫码关注微信公众号 技术岁月 支持: