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
通过这个管理界面可以查看服务的详细信息,可以测试服务,使用比较方便
为了能让虚拟机能连接网络,并且能与宿主机能相互进行访问,所以需要多虚拟机几种网络模式进行学习,以便后期能快速的进行配置。
php中的array_walk_recursive函数对数组中的每个成员递归地应用用户函数
在做搜索列表分页的时候,需要分页后的页面跳转的url地址中包含搜索的参数,在Laravel中的如何处理呢?
Composer 是 PHP 的一个依赖管理工具。我们可以在项目中声明所依赖的外部工具库,Composer 会帮你安装这些依赖的库文件,有了它,我们就可以很轻松的使用一个命令将其他人的优秀代码引用到我们的项目中来。
某些时候如果想快速将服务器中的某些资源共享给其他人,可以使用python来实现,python自带了一个快速创建HTTP服务的方式,可以将允许时目录下的所有文件以文件服务器供他人进行访问和下载。
快速生成表格
Electron页面跳转、浏览器打开链接和打开新窗口
在使用Git的过程中,不想每次都输入用户名和密码去拉取代码,所以就需要保存这些信息,那么既然有保存了,就必须有清除功能。
在Mac电脑中,如何对Git的用户名和密码进行修改呢?起初不懂Mac,所以整了很久,本文将记录如何对这个进行操作,以便后期使用。
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问题