Skip to content

lanyutc/blue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

blue

使用Golang实现的服务端框架,内置了名字发现服务,它与grpc配合实现blue的rpc,该rpc提供了基于Set的轮询、Hash调度机制,为了方便使用还内置了基于twitter-snowflake的uid生成器。

目前是一个学习性质的框架,部分功能实现利用了开源组件。

1.安装blue

git clone github.com/lanyutc/blue  

2.依赖环境

使用需要go version>=1.20

如果连接失败或者超时,你可能需要先:

export GOPROXY="https://goproxy.cn"
或者
export GOPROXY="https://goproxy.io"

3.使用例子-直接运行

3.1 准备工作

启动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

3.2 CS通信例子

启动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

3.3 RPC例子

启动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

3.4 UID生成例子

cd $your_workspace/blue/example/uidexample
go run uid.go -config=./uid.conf

4.使用例子-使用cmake(VERSION 3.25)

4.1编译

sh build.sh

4.2检查产物

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/

4.3启动与关闭

naming服务举例:

cd $your_workspace/blue/naming/bin/
./start.sh  #启动服务
./stop.sh   #停止服务

5.文档

Blue简介 - 点击打开链接
Blue的配置与日志 - 点击打开链接
Blue的CS网络通 - 点击打开链接

About

Golang服务器框架

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors