Go-Micro注册到etcd
简介Go-Micro注册到etcd
1、新版go-micro命令行已经废弃了consul,支持了etcd
2、安装etcd
参考网址:https://www.cnblogs.com/chenqionghe/p/10503840.html
3、注册更换成etcd
package main
import (
"github.com/micro/go-micro"
"github.com/micro/go-micro/registry"
"github.com/micro/go-micro/registry/etcd"
"micro-api/service/controller"
services "micro-api/service/model"
)
func main() {
registerEtcd := etcd.NewRegistry(func(options *registry.Options) {
options.Addrs = []string{
"192.168.1.171:2379",
}
})
service := micro.NewService(
micro.Name("student-service"),
micro.Registry(registerEtcd),
)
if err := services.RegisterStudentListServiceHandler(service.Server(), new(controller.StudentService)); err != nil {
}
service.Init()
service.Run()
}
4、使用micro工具包查看服务列表
#1、查看服务
> micro --registry=etcd --registry_address=192.168.1.171:2379 list services
go.micro.http.broker
student-service
#2、获取服务
> micro --registry=etcd --registry_address=192.168.1.171:2379 list services
go.micro.http.broker
student-service
E:\go\micro-student>micro --registry=etcd --registry_address=192.168.1.171:2379 get service student-service
service student-service
version 2020.03.14.14.01
ID Address Metadata
student-service-5b943dd6-3c6a-420f-b171-a2dbfc5ca88f 192.168.1.61:57953 transport=http,broker=http,protocol=mucp,registry=etcd,server=mucp
Endpoint: StudentListService.GetStudentListService
Request: {
num int32
}
Response: {
status int32
data []StudentModel
}
#3、调用服务
> micro --registry=etcd --registry_address=192.168.1.171:2379 call student-service StudentListService.GetStudentListService "{\"num\":3}"
{
"status": 200,
"data": [
{
"id": 1,
"name": "name_1",
"sex": "男"
},
{
"id": 2,
"name": "name_2",
"sex": "男"
},
{
"id": 3,
"name": "name_3",
"sex": "男"
}
]
}
5、使用micro工具的Dashboard
micro --registry=etcd --registry_address=192.168.1.171:2379 web
通过这个管理界面可以查看服务的详细信息,可以测试服务,使用比较方便
Electron页面跳转、浏览器打开链接和打开新窗口
Docker编译镜像出现:fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.12/main: temporary error (try again later)
WARNING: Ignoring APKINDEX.2c4ac24e.tar.gz: No such file or directory问题
桌面应用很多都会在系统托盘中出现,那么Flutter的开发的桌面应用该如何增加到系统托盘中呢?本文将带大家一起尝试一下.
Centos中用Chrome将网页导出为PDF,chrome --headless --print-to-pdf https://developer.chrome.com/
快速生成表格
在使用Git的过程中,不想每次都输入用户名和密码去拉取代码,所以就需要保存这些信息,那么既然有保存了,就必须有清除功能。
在Mac电脑中,如何对Git的用户名和密码进行修改呢?起初不懂Mac,所以整了很久,本文将记录如何对这个进行操作,以便后期使用。