Help us shape the future of Go! Take the 2026 Go Developer Survey

share

module
v0.0.0-...-cfef848 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2022 License: GPL-3.0

README

基于 go + grpc + consul 的微服务系统

Build Status

启动 consul

docker pull consul

docker run -d -p 8500:8500 consul

# 访问 http://127.0.0.1:8500/ui/#/dc1/services 

生成桩文件

cd $GOPATH/src/github.com/wangming1993/share/grpc/proto

docker pull registry.cn-hangzhou.aliyuncs.com/wangming/protoc:1.0

./gen-stub

启动 grpc 服务器

cd $GOPATH/src/github.com/wangming1993/share/grpc/server

# 启动hello service
go run hello/main.go

# 启动 member service
go run member/main.go

# 启动多个grpc service 以测试负载均衡
go run hello/main.go --port=1801
go run member/main.go --port=1802

客户端调用

cd $GOPATH/src/github.com/wangming1993/share/grpc/client

go run main.go

Directories

Path Synopsis
grpc
client command
proto
Package proto is a generated protocol buffer package.
Package proto is a generated protocol buffer package.
proto/common
Package common is a generated protocol buffer package.
Package common is a generated protocol buffer package.
server/hello command
server/member command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL