diff --git a/.github/RELEASE.md b/.github/RELEASE.md index d9f82550..9ea1a9d7 100644 --- a/.github/RELEASE.md +++ b/.github/RELEASE.md @@ -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. diff --git a/README.md b/README.md index eeba83d4..57ae6f3e 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/assets/readme-cn.md b/assets/readme-cn.md index fc778845..117c51e5 100644 --- a/assets/readme-cn.md +++ b/assets/readme-cn.md @@ -48,7 +48,7 @@ sponge生成代码过程中剥离了业务逻辑与非业务逻辑两大部分

-这是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)中有介绍。
@@ -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 # 用于执行各种构建、安装、分析等操作的脚本目录 @@ -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) @@ -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/)
diff --git a/cmd/protoc-gen-go-gin/internal/generate/service/template.go b/cmd/protoc-gen-go-gin/internal/generate/service/template.go index 7527830c..5c7d2171 100644 --- a/cmd/protoc-gen-go-gin/internal/generate/service/template.go +++ b/cmd/protoc-gen-go-gin/internal/generate/service/template.go @@ -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() // } // @@ -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 // } // diff --git a/cmd/protoc-gen-go-rpc-tmpl/internal/generate/service/template.go b/cmd/protoc-gen-go-rpc-tmpl/internal/generate/service/template.go index b89adc73..866a14e3 100644 --- a/cmd/protoc-gen-go-rpc-tmpl/internal/generate/service/template.go +++ b/cmd/protoc-gen-go-rpc-tmpl/internal/generate/service/template.go @@ -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}}, diff --git a/cmd/sponge/commands/init.go b/cmd/sponge/commands/init.go index 7f132a1b..554aa585 100644 --- a/cmd/sponge/commands/init.go +++ b/cmd/sponge/commands/init.go @@ -6,6 +6,8 @@ import ( "github.com/spf13/cobra" ) +const latestVersion = "latest" + // InitCommand initial sponge func InitCommand() *cobra.Command { cmd := &cobra.Command{ @@ -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 { diff --git a/cmd/sponge/commands/upgrade.go b/cmd/sponge/commands/upgrade.go index 3067f017..2359e928 100644 --- a/cmd/sponge/commands/upgrade.go +++ b/cmd/sponge/commands/upgrade.go @@ -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 { @@ -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 } @@ -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)) diff --git a/test/server/rabbitmq/docker-compose.yml b/test/server/rabbitmq/docker-compose.yml new file mode 100644 index 00000000..244ddd85 --- /dev/null +++ b/test/server/rabbitmq/docker-compose.yml @@ -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: / diff --git a/test/server/rabbitmq/plugins/enabled_plugins b/test/server/rabbitmq/plugins/enabled_plugins new file mode 100644 index 00000000..5f7cecb3 --- /dev/null +++ b/test/server/rabbitmq/plugins/enabled_plugins @@ -0,0 +1 @@ +[rabbitmq_delayed_message_exchange,rabbitmq_management,rabbitmq_prometheus]. diff --git a/test/server/rabbitmq/plugins/rabbitmq_delayed_message_exchange-3.12.0.ez b/test/server/rabbitmq/plugins/rabbitmq_delayed_message_exchange-3.12.0.ez new file mode 100644 index 00000000..3a2bced6 Binary files /dev/null and b/test/server/rabbitmq/plugins/rabbitmq_delayed_message_exchange-3.12.0.ez differ