随笔分类 -  golang微服务

摘要:安装(前提是本地已安装protobuf和protof的go扩展) go get github.com/micro/micro go get github.com/micro/go-micro go get github.com/micro/protoc-gen-micro go get github 阅读全文
posted @ 2021-05-05 11:57 GPHPER 阅读(689) 评论(0) 推荐(0)
摘要:安装consul 下载地址 https://releases.hashicorp.com/consul/,将下载的consul.exe 文件目录添加到系统环境中,然后执行 consul agent -dev 启动,默认监听8500端口,可以访问 http://127.0.0.1:8500/ 进行查看 阅读全文
posted @ 2021-05-04 13:22 GPHPER 阅读(230) 评论(0) 推荐(0)
摘要:记录下protoc生成go文件后,使用grpc调用的过程 grpc安装 go get -u -v google.golang.org/grpc server.go package main import ( "context" "fmt" "google.golang.org/grpc" "net" 阅读全文
posted @ 2021-05-03 11:32 GPHPER 阅读(178) 评论(0) 推荐(0)
摘要:先上官方使用文档 https://developers.google.cn/protocol-buffers/docs/proto3 定义proto文件 syntax = "proto3"; //.表示生成的go文件存放到当前目录下 student表示文件的包名为student option go_ 阅读全文
posted @ 2021-05-03 11:18 GPHPER 阅读(417) 评论(0) 推荐(0)
摘要:protocol buffers 是一种语言无关、平台无关、可扩展的序列化结构数据的方法,它可用于(数据)通信协议、数据存储等。总之微服务中需要使用的东西 安装protobuf 下载protobuf https://github.com/protocolbuffers/protobuf/releas 阅读全文
posted @ 2021-05-02 12:45 GPHPER 阅读(2636) 评论(0) 推荐(1)
摘要:使用rpc启动一个订单中心服务 package mainimport ( "net" "net/http" "net/rpc" "time")type OrderCenter struct {}//暴露的方法必须符合 func (t *T) MethodName(argType T1, replyT 阅读全文
posted @ 2021-05-01 14:21 GPHPER 阅读(177) 评论(0) 推荐(0)

TOP