Skip to content

go-impatient/gaea

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Jul 27, 2021
33c0c94 · Jul 27, 2021

History

22 Commits
Mar 3, 2021
Mar 3, 2021
Feb 5, 2021
Mar 3, 2021
Mar 3, 2021
Mar 3, 2021
Jan 31, 2021
Jan 31, 2021
Jul 27, 2021
Mar 3, 2021
Mar 3, 2021
Feb 28, 2021
Feb 5, 2021

Repository files navigation

Gaea['dʒi:ə] 盖亚, 一个轻量级RPC业务框架

基于 [Sniper] 轻量级业务框架 (https://github.com/go-kiss/sniper) 生成的Gaea Layout.

系统要求

  1. 类 UNIX 系统
  2. go v1.12+
  3. protoc
  4. protoc-gen-go

目录结构

├── cmd         # 服务子命令
├── dao         # 数据访问层
├── main.go     # 项目总入口
├── rpc         # 接口描述文件
├── server      # 控制器层
├── service     # 业务逻辑层
├── sniper.toml # 配置文件
└── util        # 业务工具库

快速入门

使用

编译 sniper 工具

go build ./cmd/sniper

安装 protoc-gen-twirp

# 首次使用需要安装 protoc-gen-twirp 工具
make cmd

重命名项目总包名

./sniper rename --package moocss.com/gaea 

初次生成 rpc 代码

go run cmd/sniper/main.go rpc --server auth --service user

生成 rpc 代码

# 针对指定服务
protoc --go_out=. --twirp_out=. echo.proto

针对所有服务

find rpc -name '*.proto' -exec protoc --twirp_out=. --go_out=. {} ;

建议直接使用框架提供的 make 规则

make rpc


### 测试
```bash
curl --request "POST" \
    --header "Content-Type: application/json" \
    --data '{"msg": "Hello World"}' \
    http://localhost:8080/api/helloworld.v1.Helloworld/Echo
echo 'msg:"Hello World"' \
    | protoc --encode helloworld.v1.HelloworldEchoReq ./rpc/example/v1/helloworld.proto \
    | curl -s --request POST \
      --header "Content-Type: application/protobuf" \
      --data-binary @- \
      http://localhost:8080/api/helloworld.v1.Helloworld/Echo \
    | protoc --decode helloworld.v1.HelloworldEchoResp ./rpc/example/v1/helloworld.proto

批量修改文件内容

grep -rl "检索内容" --include="*" ./ | xargs sed -i "" "s/检索内容/修改后内容/g"

redis

redis-server # 启动redis服务端
redis-cli    # 启动redis客户端
shutdown     # 关闭redis服务端

About

Gaea['dʒi:ə] 一个轻量级RPC业务框架

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages