使用Golang实现的服务端框架,内置了名字发现服务,它与grpc配合实现blue的rpc,该rpc提供了基于Set的轮询、Hash调度机制,为了方便使用还内置了基于twitter-snowflake的uid生成器。
目前是一个学习性质的框架,部分功能实现利用了开源组件。
git clone github.com/lanyutc/blue
如果连接失败或者超时,你可能需要先:
export GOPROXY="https://goproxy.cn"
或者
export GOPROXY="https://goproxy.io"
启动naming服务,默认端口8527:
cd $your_workspace/blue/naming
go run serve.go -config=./naming.conf
启动uid服务,默认端口18527:
cd $your_workspace/blue/pid_dispatch
go run serve.go -config=./pid_dispatch.conf
启动Server,默认端口44477:
cd $your_workspace/blue/example/netexample/server
go run echo_server.go -config=./echo_server.conf
启动Client:
cd $your_workspace/blue/example/netexample/client
go run echo_client.go -config=./echo_client.conf
启动RPCServer,2个进程,分别对应不同的Set调用方式
cd $your_workspace/blue/example/rpcexample/server
go run rpc_server.go -config=./rpc_server.conf
go run rpc_server.go -config=./rpc_server1.conf
启动RPCClient
cd $your_workspace/blue/example/rpcexample/client
go run rpc_client.go -config=./rpc_client.conf
cd $your_workspace/blue/example/uidexample
go run uid.go -config=./uid.conf
sh build.sh
ls $your_workspace/blue/naming/bin/
ls $your_workspace/blue/pid_dispatch/bin/
ls $your_workspace/blue/example/uidexample/bin/
ls $your_workspace/blue/example/rpcexample/server/bin/
ls $your_workspace/blue/example/rpcexample/client/bin/
ls $your_workspace/blue/example/netexample/server/bin/
ls $your_workspace/blue/example/netexample/client/bin/
naming服务举例:
cd $your_workspace/blue/naming/bin/
./start.sh #启动服务
./stop.sh #停止服务