标签:call data git handle 运行 web edit href 微服务
package main
import (
"github.com/micro/go-micro"
"github.com/micro/go-micro/registry"
"github.com/micro/go-micro/registry/etcd"
"micro/Services"
"micro/ServicesImpl"
)
func main() {
//consulReg := consul.NewRegistry(registry.Addrs("localhost:8500"))
etcdReg := etcd.NewRegistry(registry.Addrs("106.12.72.181:23791")) //注册服务到etcd中
myservice := micro.NewService(
micro.Name("test.xiahualou"+".com"),
micro.Address(":8001"),
micro.Registry(etcdReg),
)
Services.RegisterTestServiceHandler(myservice.Server(), new(ServicesImpl.TestService))
myservice.Run()
}
1.查看服務
micro --registry=etcd --registry_address=106.12.72.181:23791 list services
2.获取服务
micro --registry=etcd --registry_address=106.12.72.181:23791 get service test.xiahualou.com
3.调用服务
micro --registry=etcd --registry_address=106.12.72.181:23791 call test.xiahualou.com TestService.Call "{\"id\":3}"
# 调用的时候必须要加上Endpoint,传入的json参数key要用双引号括起来,反引号转义
micro --registry=etcd --registry_address=106.12.72.181:23791 web
21.微服务工具箱(运行时)学习:了解Micro、复习、列出所有服务
标签:call data git handle 运行 web edit href 微服务
原文地址:https://www.cnblogs.com/hualou/p/12141642.html