Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zhufuyi committed Nov 8, 2023
1 parent c183ab4 commit f552a77
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 30 deletions.
6 changes: 2 additions & 4 deletions .github/RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
## Change log

- Support setting custom request id key name.
- Add delayed queuing, publish-subscribe functionality to the pkg/rabbitmq library.
- Add clustering, sentinel functionality to pkg/goredis.
- Fix the discovered bugs.
- Support for upgrading to specific versions.
- Adjustment Authorization function.
- Update Documentation.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,18 @@ Visit `http://localhost:24631` in your browser, generate code by manipulating it

### Examples of use

#### Simple examples (excluding business logic code)
#### Simple examples

No specific business logic code is included.

- [1_web-gin-CRUD](https://github.com/zhufuyi/sponge_examples/tree/main/1_web-gin-CRUD)
- [2_web-gin-protobuf](https://github.com/zhufuyi/sponge_examples/tree/main/2_web-gin-protobuf)
- [3_micro-grpc-CRUD](https://github.com/zhufuyi/sponge_examples/tree/main/3_micro-grpc-CRUD)
- [2_micro-grpc-CRUD](https://github.com/zhufuyi/sponge_examples/tree/main/2_micro-grpc-CRUD)
- [3_web-gin-protobuf](https://github.com/zhufuyi/sponge_examples/tree/main/3_web-gin-protobuf)
- [4_micro-grpc-protobuf](https://github.com/zhufuyi/sponge_examples/tree/main/4_micro-grpc-protobuf)
- [5_micro-gin-rpc-gateway](https://github.com/zhufuyi/sponge_examples/tree/main/5_micro-gin-rpc-gateway)
- [6_micro-cluster](https://github.com/zhufuyi/sponge_examples/tree/main/6_micro-cluster)
- [6_micro-cluster-demo](https://github.com/zhufuyi/sponge_examples/tree/main/6_micro-cluster)

#### Full project examples (including business logic code)
#### Complete project examples

- [7_community-single](https://github.com/zhufuyi/sponge_examples/tree/main/7_community-single)
- [8_community-cluster](https://github.com/zhufuyi/sponge_examples/tree/main/8_community-cluster)
Expand Down
27 changes: 13 additions & 14 deletions assets/readme-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ sponge生成代码过程中剥离了业务逻辑与非业务逻辑两大部分
<img width="1200px" src="https://raw.githubusercontent.com/zhufuyi/sponge_examples/main/assets/web-http-pb-anatomy.png">
</p>

这是web服务代码鸡蛋模型,还有微服务(gRPC)代码、rpc网关服务代码的鸡蛋模型在[sponge文档](https://go-sponge.com/zh-cn/learn-about-sponge?id=%f0%9f%8f%b7%e9%a1%b9%e7%9b%ae%e4%bb%a3%e7%a0%81%e9%b8%a1%e8%9b%8b%e6%a8%a1%e5%9e%8b)中有介绍。
这是web服务代码鸡蛋模型,还有微服务(grpc)代码、grpc网关服务代码的鸡蛋模型在[sponge文档](https://go-sponge.com/zh-cn/learn-about-sponge?id=%f0%9f%8f%b7%e9%a1%b9%e7%9b%ae%e4%bb%a3%e7%a0%81%e9%b8%a1%e8%9b%8b%e6%a8%a1%e5%9e%8b)中有介绍。

<br>

Expand Down Expand Up @@ -99,9 +99,9 @@ sponge包含丰富的组件(按需使用):
│ ├── handler # http的业务功能实现目录
│ ├── model # 数据库模型目录
│ ├── routers # http路由目录
│ ├── rpcclient # 连接rpc服务的客户端目录
│ ├── server # 服务入口,包括http、rpc等
│ ├── service # rpc的业务功能实现目录
│ ├── rpcclient # 连接grpc服务的客户端目录
│ ├── server # 服务入口,包括http、grpc等
│ ├── service # grpc的业务功能实现目录
│ └── types # http的请求和响应类型目录
├── pkg # 外部应用程序可以使用的库目录
├── scripts # 用于执行各种构建、安装、分析等操作的脚本目录
Expand Down Expand Up @@ -137,18 +137,18 @@ sponge run

#### 简单示例

不包括业务逻辑代码
不包含具体业务逻辑代码

- [1_web-gin-CRUD](https://github.com/zhufuyi/sponge_examples/tree/main/1_web-gin-CRUD)
- [2_web-gin-protobuf](https://github.com/zhufuyi/sponge_examples/tree/main/2_web-gin-protobuf)
- [3_micro-grpc-CRUD](https://github.com/zhufuyi/sponge_examples/tree/main/3_micro-grpc-CRUD)
- [2_micro-grpc-CRUD](https://github.com/zhufuyi/sponge_examples/tree/main/2_micro-grpc-CRUD)
- [3_web-gin-protobuf](https://github.com/zhufuyi/sponge_examples/tree/main/3_web-gin-protobuf)
- [4_micro-grpc-protobuf](https://github.com/zhufuyi/sponge_examples/tree/main/4_micro-grpc-protobuf)
- [5_micro-gin-rpc-gateway](https://github.com/zhufuyi/sponge_examples/tree/main/5_micro-gin-rpc-gateway)
- [6_micro-cluster](https://github.com/zhufuyi/sponge_examples/tree/main/6_micro-cluster)

#### 完整项目示例

包括业务逻辑代码
包括具体业务逻辑代码

- [7_community-single](https://github.com/zhufuyi/sponge_examples/tree/main/7_community-single)
- [8_community-cluster](https://github.com/zhufuyi/sponge_examples/tree/main/8_community-cluster)
Expand All @@ -165,14 +165,13 @@ sponge run
- [04 批量生成CRUD接口代码到web服务](https://www.bilibili.com/video/BV1AY411C7J7/)
- [05 一键生成通用的web服务项目代码](https://www.bilibili.com/video/BV1CX4y1D7xj/)
- [06 批量生成任意API接口代码到web服务](https://www.bilibili.com/video/BV1P54y1g7J9/)
- [07 一键生成微服务(gRPC)完整项目代码](https://www.bilibili.com/video/BV1Tg4y1b79U/)
- [07 一键生成微服务(grpc)完整项目代码](https://www.bilibili.com/video/BV1Tg4y1b79U/)
- [08 批量生成CRUD代码到微服务项目代码](https://www.bilibili.com/video/BV1TY411z7rY/)
- [09 一键生成通用的微服务(gRPC)项目代码](https://www.bilibili.com/video/BV1WY4y1X7zH/)
- [10 批量生成rpc方法代码到微服务](https://www.bilibili.com/video/BV1Yo4y1q76o/)
- [11 rpc测试神器,简单便捷](https://www.bilibili.com/video/BV1VT411z7oj/)
- [12 一键生成rpc网关服务项目代码](https://www.bilibili.com/video/BV1mV4y1D7k9/)
- [09 一键生成通用的微服务(grpc)项目代码](https://www.bilibili.com/video/BV1WY4y1X7zH/)
- [10 批量生成grpc方法代码到微服务](https://www.bilibili.com/video/BV1Yo4y1q76o/)
- [11 grpc测试神器,简单便捷](https://www.bilibili.com/video/BV1VT411z7oj/)
- [12 一键生成grpc网关服务项目代码](https://www.bilibili.com/video/BV1mV4y1D7k9/)
- [13 十分钟搭建一个微服务集群示例](https://www.bilibili.com/video/BV1YM4y127YK/)
- [14 用chatGPT打造你的专属面试题库](https://www.bilibili.com/video/BV1V24y1w7wG/)

<br>

Expand Down
4 changes: 2 additions & 2 deletions cmd/protoc-gen-go-gin/internal/generate/service/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (c *{{.LowerServiceName}}Client) {{.MethodName}}(ctx context.Context, req *
// example:
// err := req.Validate()
// if err != nil {
// logger.Warn("req.Validate error", logger.Err(err), logger.Any("req", req), interceptor.ClientCtxRequestIDField(ctx))
// logger.Warn("req.Validate error", logger.Err(err), logger.Any("req", req), interceptor.CtxRequestIDField(ctx))
// return nil, ecode.StatusInvalidParams.Err()
// }
//
Expand All @@ -75,7 +75,7 @@ func (c *{{.LowerServiceName}}Client) {{.MethodName}}(ctx context.Context, req *
{{- end}}
// })
// if err != nil {
// logger.Warn("{{.MethodName}} error", logger.Err(err), interceptor.ClientCtxRequestIDField(ctx))
// logger.Warn("{{.MethodName}} error", logger.Err(err), interceptor.CtxRequestIDField(ctx))
// return nil, err
// }
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ func (s *{{.LowerServiceName}}) {{.MethodName}}(ctx context.Context, req *server
// logger.Warn("req.Validate error", logger.Err(err), logger.Any("req", req), interceptor.ServerCtxRequestIDField(ctx))
// return nil, ecode.StatusInvalidParams.Err()
// }
// ctx = interceptor.WrapServerCtx(ctx)
//
// ctx = context.WithValue(ctx, interceptor.ContextRequestIDKey, interceptor.ServerCtxRequestID(ctx))
// reply, err := s.iDao.{{.MethodName}}(ctx, &model.{{.ServiceName}}{
{{- range .RequestFields}}
// {{.Name}}: req.{{.Name}},
Expand Down
4 changes: 3 additions & 1 deletion cmd/sponge/commands/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"github.com/spf13/cobra"
)

const latestVersion = "latest"

// InitCommand initial sponge
func InitCommand() *cobra.Command {
cmd := &cobra.Command{
Expand All @@ -22,7 +24,7 @@ Examples:
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("initialize sponge ......")

targetVersion := "latest"
targetVersion := latestVersion
// download sponge template code
_, err := runUpgrade(targetVersion)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions cmd/sponge/commands/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Examples:
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("upgrade sponge ......")
if targetVersion == "" {
targetVersion = "latest"
targetVersion = latestVersion
}
ver, err := runUpgrade(targetVersion)
if err != nil {
Expand All @@ -46,7 +46,7 @@ Examples:
},
}

cmd.Flags().StringVarP(&targetVersion, "version", "v", "latest", "upgrade sponge version")
cmd.Flags().StringVarP(&targetVersion, "version", "v", latestVersion, "upgrade sponge version")
return cmd
}

Expand Down Expand Up @@ -96,7 +96,7 @@ func copyToTempDir(targetVersion string) (string, error) {
}

spongeDirName := ""
if targetVersion == "latest" {
if targetVersion == latestVersion {
// find the new version of the sponge code directory
arg := fmt.Sprintf("%s/pkg/mod/github.com/zhufuyi", gopath)
result, err = gobash.Exec("ls", adaptPathDelimiter(arg))
Expand Down
20 changes: 20 additions & 0 deletions test/server/rabbitmq/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '3'

services:
rabbitmq:
image: rabbitmq:3.12-management
container_name: rabbitmq
hostname: rabbitmq-service
restart: always
ports:
- 5672:5672
- 15672:15672
volumes:
- $PWD/data:/var/lib/rabbitmq
- $PWD/plugins/enabled_plugins:/etc/rabbitmq/enabled_plugins
- $PWD/plugins/rabbitmq_delayed_message_exchange-3.12.0.ez:/plugins/rabbitmq_delayed_message_exchange-3.12.0.ez
environment:
TZ: Asia/Shanghai
RABBITMQ_DEFAULT_USER: guest
RABBITMQ_DEFAULT_PASS: guest
RABBITMQ_DEFAULT_VHOST: /
1 change: 1 addition & 0 deletions test/server/rabbitmq/plugins/enabled_plugins
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[rabbitmq_delayed_message_exchange,rabbitmq_management,rabbitmq_prometheus].
Binary file not shown.

0 comments on commit f552a77

Please sign in to comment.