Skip to content

Commit 446d528

Browse files
committed
update README
1 parent acdcb11 commit 446d528

File tree

4 files changed

+93
-20
lines changed

4 files changed

+93
-20
lines changed

README.md

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
Sponge's core design concept is to reversely generate modular code through `SQL` or `Protobuf` files. These codes can be flexibly and seamlessly combined into various types of backend services, thus greatly improving development efficiency and simplifying backend service development. Sponge's main goals are as follows:
2525

2626
- If you develop a web or gRPC service with only CRUD API, you don't need to write any go code to compile and deploy it to Linux servers, dockers, k8s, and you just need to connect to the database to automatically generate the complete backend service go code by sponge.
27-
- If you develop general web, gRPC, http+gRPC, gRPC gateway services, you only need to focus on the three core parts of `define tables in the database`, `define API description information in the proto file`, and `fill in business logic code in the generated template file`, and other go codes (including CRUD api) are generated by sponge.
27+
- If you develop general web, gRPC, http+gRPC, gRPC gateway services, you only need to focus on the three core parts of `define tables in the database`, `define API description information in the protobuf file`, and `fill in business logic code in the generated template file`, and other go codes (including CRUD api) are generated by sponge.
2828

2929
<br>
3030

@@ -83,6 +83,7 @@ Click to view the [**test code**](https://github.com/zhufuyi/microservices_frame
8383
- Crontab [cron](https://github.com/robfig/cron)
8484
- Message Queue [rabbitmq](https://github.com/rabbitmq/amqp091-go), [kafka](https://github.com/IBM/sarama)
8585
- Distributed Transaction Manager [dtm](https://github.com/dtm-labs/dtm)
86+
- Distributed lock [dlock](https://github.com/zhufuyi/sponge/tree/main/pkg/dlock)
8687
- Parameter validation [validator](https://github.com/go-playground/validator)
8788
- Adaptive rate limiting [ratelimit](https://github.com/zhufuyi/sponge/tree/main/pkg/shield/ratelimit)
8889
- Adaptive circuit breaking [circuitbreaker](https://github.com/zhufuyi/sponge/tree/main/pkg/shield/circuitbreaker)
@@ -98,20 +99,19 @@ Click to view the [**test code**](https://github.com/zhufuyi/microservices_frame
9899

99100
### Project Code Directory Structure
100101

101-
The project code directory structure created by sponge follows the [project-layout](https://github.com/golang-standards/project-layout) and is structured as follows. Supported repository types are `monolithic application single repository (monolith)`, `microservice multi-repository (multi-repo)`, `microservice single repository (mono-repo)`.
102+
The project code directory structure created by sponge follows the [project-layout](https://github.com/golang-standards/project-layout).
103+
104+
Here is the directory structure for the generated `monolithic application single repository (monolith)` or `microservice multi-repository (multi-repo)` code:
102105

103106
```bash
104107
.
105-
├── api # Directory for exposing external API interfaces, typically containing proto files and generated *.pb.go files. The directory structure is typically in the form `api/xxx/v1`, where v1 indicates the version.
108+
├── api # Protobuf files and generated * pb.go directory
106109
├── assets # Store various static resources, such as images, markdown files, etc.
107110
├── cmd # Program entry directory
108-
│ └── serviceName
109-
│ ├── initial # Program initialization, consisting of three files: initApp initializes configurations, registerServers registers services (HTTP or grpc), and registerClose registers resource cleanup.
110-
│ └── main.go # Program entry file
111111
├── configs # Directory for configuration files
112-
├── deployments # Directory for deployment scripts, supporting Bare Metal, Docker and Kubernetes deployments.
113-
├─ docs # Directory for API interface Swagger documentation.
114-
├── i(I)nternal # Directory for business logic code, if the first letter is lowercase (internal), it means private code, if the first letter is capitalised (Internal), it means it can be reused by other code.
112+
├── deployments # Bare metal, docker, k8s deployment script directory.
113+
├─ docs # Directory for API interface Swagger documentation.
114+
├── internal # Directory for business logic code.
115115
│ ├── cache # Cache directory wrapped around business logic.
116116
│ ├── config # Directory for Go structure configuration files.
117117
│ ├── dao # Data access directory.
@@ -124,9 +124,32 @@ The project code directory structure created by sponge follows the [project-layo
124124
│ ├── service # Directory for implementing grpc business functionality (specific to grpc services).
125125
│ └── types # Directory for defining request and response parameter structures for HTTP.
126126
├── pkg # Directory for shared libraries.
127-
├── scripts # Directory for scripts, including compilation, execution, code generation, and deployment scripts.
127+
├── scripts # Directory for scripts.
128128
├── test # Directory for scripts required for testing services and test SQL.
129-
└── third_party # Directory for external helper programs, forked code, and other third-party tools.
129+
├── third_party # Directory for third-party protobuf files or external helper programs.
130+
├── Makefile # Develop, test, deploy related command sets .
131+
├── go.mod # Go module dependencies and version control file.
132+
└── go.sum # Go module dependencies key and checksum file.
133+
```
134+
135+
<br>
136+
137+
Here is the directory structure for the generated `microservice monolithic repository (mono-repo)` code (also known as large repository directory structure):
138+
139+
```bash
140+
.
141+
├── api
142+
│ ├── server1 # Protobuf files and generated *pb.go directory for service 1.
143+
│ ├── server2 # Protobuf files and generated *pb.go directory for service 2.
144+
│ ├── server3 # Protobuf files and generated *pb.go directory for service 3.
145+
│ └── ...
146+
├── server1 # Code directory for Service 1, it has a similar structure to the microservice multi repo directory.
147+
├── server2 # Code directory for Service 2, it has a similar structure to the microservice multi repo directory.
148+
├── server3 # Code directory for Service 3, it has a similar structure to the microservice multi repo directory.
149+
├── ...
150+
├── third_party # Third-party protobuf files.
151+
├── go.mod # Go module dependencies and version control file.
152+
└── go.sum # Go module dependencies' checksums and hash keys.
130153
```
131154

132155
<br>

assets/install-cn.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@
1111

1212
### Windows环境
1313

14+
安装sponge之前确保已安装go语言环境,并把`GOBIN`添加到系统环境变量**path**,如果已经设置过可以跳过此步骤:
15+
16+
```bash
17+
# 检查GOBIN目录是否存在
18+
go env GOBIN
19+
20+
# 如果为空,设置GOBIN(例如:D:\go\bin),可能需要管理员权限
21+
go env -w GOBIN=D:\go\bin
22+
# 然后并把GOBIN目录添加到系统path环境变量
23+
```
24+
25+
<br>
26+
1427
> 因为sponge依赖一些linux命令,因此在windows环境中需要安装git bash、make来支持linux命令环境。
1528
1629
为了安装方便,已经把sponge及其依赖的程序打包在一起,下载地址(选择一个下载即可):
@@ -25,7 +38,7 @@
2538
(2) 在任意文件夹下右键(显示更多选项),选择【Open Git Bash here】打开git bash终端:
2639

2740
```bash
28-
# 初始化sponge,自动安装sponge依赖插件
41+
# 初始化sponge
2942
sponge init
3043

3144
# 查看sponge版本

assets/install-en.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,21 @@ Recommended to use go version 1.20 or above, [https://go.dev/doc/install](https:
99

1010
### Windows Environment
1111

12-
> Because sponge depends on some linux commands, git bash and make need to be installed in windows to support the linux command environment.
12+
Make sure the go locale is installed before installing sponge, and add `GOBIN` to the system environment variable **path**. If it is already set, skip this step:
13+
14+
```bash
15+
#Check if GOBIN directory exists
16+
go env GOBIN
17+
18+
#If empty, GOBIN needs to be set (e.g. D:\go\bin), administrator privileges may be required
19+
go env -w GOBIN=D:\go\bin
20+
#Then add GOBIN directory to system path environment variable
21+
```
1322

1423
<br>
1524

25+
> Because sponge depends on some linux commands, git bash and make need to be installed in windows to support the linux command environment.
26+
1627
For installation convenience, sponge and its dependent programs have been packaged together, download address: [sponge-install.zip](https://drive.google.com/drive/folders/1T55lLXDBIQCnL5IQ-i1hWJovgLI2l0k1?usp=sharing)
1728

1829
After downloading the file:

assets/readme-cn.md

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
sponge 的核心设计理念是通过 `SQL``Protobuf` 文件逆向生成模块化的代码,这些代码可以灵活、无缝地组合成多种类型的后端服务,从而大大提升开发效率,简化后端服务开发,sponge 的主要目标如下:
1212

1313
- 如果开发只有 CRUD api 的 web 或 gRPC 服务,不需要编写任何 go 代码就可以编译并部署到 linux 服务器、docker、k8s 上,只需要连接到数据库就可以一键自动生成完整的后端服务 go 代码。
14-
- 如果开发通用的 web、gRPC、http+gRPC、gRPC 网关等服务,只需聚焦`在数据库定义表``在proto文件定义api描述信息``在生成的模板文件填写业务逻辑代码`三个核心部分,其他 go 代码(包括CRUD api)都由 sponge 来生成。
14+
- 如果开发通用的 web、gRPC、http+gRPC、gRPC 网关等服务,只需聚焦`在数据库定义表``在protobuf文件定义api描述信息``在生成的模板文件填写业务逻辑代码`三个核心部分,其他 go 代码(包括CRUD api)都由 sponge 来生成。
1515

1616
<br>
1717

@@ -71,6 +71,7 @@ sponge包含丰富的组件(按需使用):
7171
- 定时任务 [cron](https://github.com/robfig/cron)
7272
- 消息队列组件 [rabbitmq](https://github.com/rabbitmq/amqp091-go), [kafka](https://github.com/IBM/sarama)
7373
- 分布式事务管理器 [dtm](https://github.com/dtm-labs/dtm)
74+
- 分布式锁 [dlock](https://github.com/zhufuyi/sponge/tree/main/pkg/dlock)
7475
- 自适应限流 [ratelimit](https://github.com/zhufuyi/sponge/tree/main/pkg/shield/ratelimit)
7576
- 自适应熔断 [circuitbreaker](https://github.com/zhufuyi/sponge/tree/main/pkg/shield/circuitbreaker)
7677
- 链路跟踪 [opentelemetry](https://github.com/open-telemetry/opentelemetry-go)
@@ -85,17 +86,19 @@ sponge包含丰富的组件(按需使用):
8586

8687
### 目录结构
8788

88-
生成的服务代码目录结构遵循 [project-layout](https://github.com/golang-standards/project-layout),代码目录结构如下所示。支持的仓库类型有`单体应用单体仓库(monolith)``微服务多仓库(multi-repo)``微服务单体仓库(mono-repo)`
89+
生成的服务代码目录结构遵循 [project-layout](https://github.com/golang-standards/project-layout)
90+
91+
这是生成的`单体应用单体仓库(monolith)``微服务多仓库(multi-repo)`代码目录结构:
8992

9093
```bash
9194
.
92-
├── api # proto文件和生成的*pb.go目录
95+
├── api # protobuf文件和生成的*pb.go目录
9396
├── assets # 其他与资源库一起使用的资产(图片、logo等)目录
9497
├── cmd # 程序入口目录
9598
├── configs # 配置文件的目录
96-
├── deployments # IaaS、PaaS、系统和容器协调部署的配置和模板目录
99+
├── deployments # 裸机、docker、k8s部署脚本目录
97100
├── docs # 设计文档和界面文档目录
98-
├── internal # 业务逻辑代码目录,表示私有代码。
101+
├── internal # 业务逻辑代码目录
99102
│ ├── cache # 基于业务包装的缓存目录
100103
│ ├── config # Go结构的配置文件目录
101104
│ ├── dao # 数据访问目录
@@ -108,9 +111,32 @@ sponge包含丰富的组件(按需使用):
108111
│ ├── service # grpc的业务功能实现目录
109112
│ └── types # http的请求和响应类型目录
110113
├── pkg # 外部应用程序可以使用的库目录
111-
├── scripts # 用于执行各种构建、安装、分析等操作的脚本目录
114+
├── scripts # 执行脚本目录
112115
├── test # 额外的外部测试程序和测试数据
113-
└── third_party # 外部帮助程序、分叉代码和其他第三方工具
116+
├── third_party # 依赖第三方protobuf文件或其他工具的目录
117+
├── Makefile # 开发、测试、部署相关的命令集合
118+
├── go.mod # go 模块依赖关系和版本控制文件
119+
└── go.sum # go 模块依赖项的密钥和校验文件
120+
```
121+
122+
<br>
123+
124+
这是生成的`微服务单体仓库(mono-repo)`代码目录结构(也就是大仓库代码目录结构):
125+
126+
```bash
127+
.
128+
├── api
129+
│ ├── server1 # 服务1的protobuf文件和生成的*pb.go目录
130+
│ ├── server2 # 服务2的protobuf文件和生成的*pb.go目录
131+
│ ├── server3 # 服务3的protobuf文件和生成的*pb.go目录
132+
│ └── ...
133+
├── server1 # 服务1的代码目录,与微服务多仓库(multi-repo)目录结构基本一样
134+
├── server2 # 服务2的代码目录,与微服务多仓库(multi-repo)目录结构基本一样
135+
├── server3 # 服务3的代码目录,与微服务多仓库(multi-repo)目录结构基本一样
136+
├── ...
137+
├── third_party # 依赖的第三方protobuf文件
138+
├── go.mod # go 模块依赖关系和版本控制文件
139+
└── go.sum # go 模块依赖项的密钥和校验和文件
114140
```
115141

116142
<br>

0 commit comments

Comments
 (0)