mirror of https://github.com/zhufuyi/sponge
docs: update readme
This commit is contained in:
parent
e7dcb143dd
commit
ad8c295e5d
193
README.md
193
README.md
|
@ -9,24 +9,27 @@
|
|||
[](https://goreportcard.com/report/github.com/go-dev-frame/sponge)
|
||||
[](https://codecov.io/gh/go-dev-frame/sponge)
|
||||
[](https://pkg.go.dev/github.com/go-dev-frame/sponge)
|
||||
[](https://github.com/go-dev-frame/sponge/actions)
|
||||
[](https://github.com/go-dev-frame/sponge/actions)
|
||||
[](https://github.com/avelino/awesome-go)
|
||||
[](https://img.shields.io/github/license/go-dev-frame/sponge)
|
||||
|
||||
</div>
|
||||
|
||||
**sponge** is a powerful `Go` development framework. Its core concept revolves around reverse-engineering modular code by parsing `JSON`, `SQL`, or `Protobuf` files. The generated code can be flexibly and seamlessly assembled into various types of complete backend services (similar to the characteristics of sponge cells, where disassembled sponge cells can automatically recombine into a new sponge). Sponge provides an all-in-one solution for project development, covering code generation, development, testing, API documentation, and deployment, significantly enhancing development efficiency, reducing complexity, and enabling high-quality projects with a "low-code approach".
|
||||
**Sponge** is a powerful `Go` development framework. Its core concept revolves around reverse-engineering modular code by parsing `JSON`, `SQL`, or `Protobuf` files. The generated code can be flexibly and seamlessly assembled into various types of complete backend services (`similar to the characteristics of sponge cells, where disassembled sponge cells can automatically recombine into a new sponge`).
|
||||
|
||||
Sponge provides an all-in-one solution for project development, covering code generation, development, testing, API documentation, and deployment, significantly enhancing development efficiency, reducing complexity, and enabling high-quality projects with a "low-code approach".
|
||||
|
||||
<br>
|
||||
|
||||
### Use Cases
|
||||
### Applicable scenarios
|
||||
|
||||
Sponge is suitable for quickly developing various high-performance backend services, including but not limited to:
|
||||
|
||||
- `Web` services (gin);
|
||||
- `gRPC` services;
|
||||
- `HTTP+gRPC` hybrid services;
|
||||
- `gRPC Gateway API` services.
|
||||
- `gRPC Gateway API` services;
|
||||
- cloud-native microservices.
|
||||
|
||||
Additionally, developers can use custom templates to generate various types of code to meet specific business needs.
|
||||
|
||||
|
@ -53,6 +56,8 @@ Additionally, developers can use custom templates to generate various types of c
|
|||
- Test code;
|
||||
- Build and deployment scripts, etc.
|
||||
|
||||
4. **Generate code on the page, simple and easy to use**
|
||||
|
||||
<br>
|
||||
|
||||
### Quick Start
|
||||
|
@ -79,54 +84,16 @@ Additionally, developers can use custom templates to generate various types of c
|
|||
|
||||
<br>
|
||||
|
||||
### Sponge Generates the Code Framework
|
||||
### Main Features
|
||||
|
||||
Sponge supports generating code using both built-in templates and custom templates, as shown in the diagrams below.
|
||||
|
||||
1. The code generation framework based on Sponge's built-in templates is shown below. There are two approaches: SQL and Protobuf.
|
||||
|
||||
<p align="center">
|
||||
<img width="1500px" src="https://raw.githubusercontent.com/go-dev-frame/sponge/main/assets/sponge-framework.png">
|
||||
</p>
|
||||
|
||||
<br>
|
||||
|
||||
2. The code generation framework based on custom templates is shown below. There are three approaches: JSON, SQL, and Protobuf.
|
||||
|
||||
<p align="center">
|
||||
<img width="1200px" src="https://raw.githubusercontent.com/go-dev-frame/sponge/main/assets/template-framework.png">
|
||||
</p>
|
||||
|
||||
<br>
|
||||
|
||||
### Microservice framework
|
||||
|
||||
Sponge supports creating six types of backend services, all based on microservice architecture. The diagram below illustrates a typical layered microservice structure, featuring high performance, scalability, and built-in service governance capabilities.
|
||||
|
||||
<p align="center">
|
||||
<img width="1000px" src="https://raw.githubusercontent.com/go-dev-frame/sponge/main/assets/microservices-framework.png">
|
||||
</p>
|
||||
|
||||
<br>
|
||||
|
||||
Performance testing of http and grpc service code created by the microservices framework: 50 concurrent, 1 million total requests.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
Click to view the [**test code**](https://github.com/zhufuyi/microservices_framework_benchmark).
|
||||
|
||||
<br>
|
||||
|
||||
### Key Features
|
||||
Sponge has built-in rich features (for on-demand use):
|
||||
|
||||
- Web framework [gin](https://github.com/gin-gonic/gin)
|
||||
- RPC framework [grpc](https://github.com/grpc/grpc-go)
|
||||
- Configuration parsing [viper](https://github.com/spf13/viper)
|
||||
- Logging component [zap](https://github.com/uber-go/zap)
|
||||
- Database ORM component [gorm](https://github.com/go-gorm/gorm), [mongo-go-driver](https://github.com/mongodb/mongo-go-driver)
|
||||
- Cache component [go-redis](https://github.com/go-redis/redis), [ristretto](https://github.com/dgraph-io/ristretto)
|
||||
- ORM framework [gorm](https://github.com/go-gorm/gorm), [mongo-go-driver](https://github.com/mongodb/mongo-go-driver)
|
||||
- Cache [go-redis](https://github.com/go-redis/redis), [ristretto](https://github.com/dgraph-io/ristretto)
|
||||
- Automated API documentation [swagger](https://github.com/swaggo/swag), [protoc-gen-openapiv2](https://github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2)
|
||||
- Authentication [jwt](https://github.com/golang-jwt/jwt)
|
||||
- Websocket [gorilla/websocket](https://github.com/gorilla/websocket)
|
||||
|
@ -150,61 +117,103 @@ Click to view the [**test code**](https://github.com/zhufuyi/microservices_frame
|
|||
|
||||
<br>
|
||||
|
||||
### Generates Code Framework
|
||||
|
||||
Sponge supports generating code using both built-in templates and custom templates, as shown in the diagrams below.
|
||||
|
||||
1. The code generation framework based on Sponge's built-in templates is shown below. There are two approaches: SQL and Protobuf.
|
||||
|
||||
<p align="center">
|
||||
<img width="1500px" src="https://raw.githubusercontent.com/go-dev-frame/sponge/main/assets/sponge-framework.png">
|
||||
</p>
|
||||
|
||||
<br>
|
||||
|
||||
2. The code generation framework based on custom templates is shown below. There are three approaches: JSON, SQL, and Protobuf.
|
||||
|
||||
<p align="center">
|
||||
<img width="1200px" src="https://raw.githubusercontent.com/go-dev-frame/sponge/main/assets/template-framework.png">
|
||||
</p>
|
||||
|
||||
<br>
|
||||
|
||||
### Microservice framework
|
||||
|
||||
Five of the six types of back-end services created by sponge are microservice architectures. The diagram below illustrates a typical layered microservice structure, featuring high performance, scalability, and built-in service governance capabilities.
|
||||
|
||||
<p align="center">
|
||||
<img width="1000px" src="https://raw.githubusercontent.com/go-dev-frame/sponge/main/assets/microservices-framework.png">
|
||||
</p>
|
||||
|
||||
<br>
|
||||
|
||||
Performance testing of http and grpc service code created by the microservices framework: 50 concurrent, 1 million total requests.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
Click to view the [**test code**](https://github.com/zhufuyi/microservices_framework_benchmark).
|
||||
|
||||
<br>
|
||||
|
||||
### Project Code Directory Structure
|
||||
|
||||
The project code directory structure created by sponge follows the [project-layout](https://github.com/golang-standards/project-layout).
|
||||
|
||||
Here is the directory structure for the generated `monolithic application single repository (monolith)` or `microservice multi-repository (multi-repo)` code:
|
||||
Sponge supports creating three types of project code structures: `Monolithic application monorepo (monolith)`, `Microservices multi-repo (multi-repo)`, and `Microservices monorepo (mono-repo)`.
|
||||
|
||||
```bash
|
||||
.
|
||||
├── api # Protobuf files and generated * pb.go directory
|
||||
├── assets # Store various static resources, such as images, markdown files, etc.
|
||||
├── cmd # Program entry directory
|
||||
├── configs # Directory for configuration files
|
||||
├── deployments # Bare metal, docker, k8s deployment script directory.
|
||||
├── docs # Directory for API interface Swagger documentation.
|
||||
├── internal # Directory for business logic code.
|
||||
│ ├── cache # Cache directory wrapped around business logic.
|
||||
│ ├── config # Directory for Go structure configuration files.
|
||||
│ ├── dao # Data access directory.
|
||||
│ ├── database # database directory.
|
||||
│ ├── ecode # Directory for system error codes and custom business error codes.
|
||||
│ ├── handler # Directory for implementing HTTP business functionality (specific to web services).
|
||||
│ ├── model # Database model directory.
|
||||
│ ├── routers # HTTP routing directory.
|
||||
│ ├── rpcclient # Directory for client-side code that connects to grpc services.
|
||||
│ ├── server # Directory for creating services, including HTTP and grpc.
|
||||
│ ├── service # Directory for implementing grpc business functionality (specific to grpc services).
|
||||
│ └── types # Directory for defining request and response parameter structures for HTTP.
|
||||
├── pkg # Directory for shared libraries.
|
||||
├── scripts # Directory for scripts.
|
||||
├── test # Directory for scripts required for testing services and test SQL.
|
||||
├── third_party # Directory for third-party protobuf files or external helper programs.
|
||||
├── Makefile # Develop, test, deploy related command sets .
|
||||
├── go.mod # Go module dependencies and version control file.
|
||||
└── go.sum # Go module dependencies key and checksum file.
|
||||
```
|
||||
1. The code directory structure for creating a `Monolithic application monorepo (monolith)` or `Microservices multi-repo (multi-repo)` is as follows:
|
||||
|
||||
```bash
|
||||
.
|
||||
├── api # Protobuf files and generated * pb.go directory
|
||||
├── assets # Store various static resources, such as images, markdown files, etc.
|
||||
├── cmd # Program entry directory
|
||||
├── configs # Directory for configuration files
|
||||
├── deployments # Bare metal, docker, k8s deployment script directory.
|
||||
├── docs # Directory for API interface Swagger documentation.
|
||||
├── internal # Directory for business logic code.
|
||||
│ ├── cache # Cache directory wrapped around business logic.
|
||||
│ ├── config # Directory for Go structure configuration files.
|
||||
│ ├── dao # Data access directory.
|
||||
│ ├── database # database directory.
|
||||
│ ├── ecode # Directory for system error codes and custom business error codes.
|
||||
│ ├── handler # Directory for implementing HTTP business functionality (specific to web services).
|
||||
│ ├── model # Database model directory.
|
||||
│ ├── routers # HTTP routing directory.
|
||||
│ ├── rpcclient # Directory for client-side code that connects to grpc services.
|
||||
│ ├── server # Directory for creating services, including HTTP and grpc.
|
||||
│ ├── service # Directory for implementing grpc business functionality (specific to grpc services).
|
||||
│ └── types # Directory for defining request and response parameter structures for HTTP.
|
||||
├── pkg # Directory for shared libraries.
|
||||
├── scripts # Directory for scripts.
|
||||
├── test # Directory for scripts required for testing services and test SQL.
|
||||
├── third_party # Directory for third-party protobuf files or external helper programs.
|
||||
├── Makefile # Develop, test, deploy related command sets .
|
||||
├── go.mod # Go module dependencies and version control file.
|
||||
└── go.sum # Go module dependencies key and checksum file.
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
Here is the directory structure for the generated `microservice monolithic repository (mono-repo)` code (also known as large repository directory structure):
|
||||
2. The code directory structure for creating a `Microservices monorepo (mono-repo)` (large repository code directory structure) is as follows:
|
||||
|
||||
```bash
|
||||
.
|
||||
├── api
|
||||
│ ├── server1 # Protobuf files and generated *pb.go directory for service 1.
|
||||
│ ├── server2 # Protobuf files and generated *pb.go directory for service 2.
|
||||
│ ├── server3 # Protobuf files and generated *pb.go directory for service 3.
|
||||
│ └── ...
|
||||
├── server1 # Code directory for Service 1, it has a similar structure to the microservice multi repo directory.
|
||||
├── server2 # Code directory for Service 2, it has a similar structure to the microservice multi repo directory.
|
||||
├── server3 # Code directory for Service 3, it has a similar structure to the microservice multi repo directory.
|
||||
├── ...
|
||||
├── third_party # Third-party protobuf files.
|
||||
├── go.mod # Go module dependencies and version control file.
|
||||
└── go.sum # Go module dependencies' checksums and hash keys.
|
||||
```
|
||||
```bash
|
||||
.
|
||||
├── api
|
||||
│ ├── server1 # Protobuf files and generated *pb.go directory for service 1.
|
||||
│ ├── server2 # Protobuf files and generated *pb.go directory for service 2.
|
||||
│ ├── server3 # Protobuf files and generated *pb.go directory for service 3.
|
||||
│ └── ...
|
||||
├── server1 # Code directory for Service 1, it has a similar structure to the microservice multi repo directory.
|
||||
├── server2 # Code directory for Service 2, it has a similar structure to the microservice multi repo directory.
|
||||
├── server3 # Code directory for Service 3, it has a similar structure to the microservice multi repo directory.
|
||||
├── ...
|
||||
├── third_party # Third-party protobuf files.
|
||||
├── go.mod # Go module dependencies and version control file.
|
||||
└── go.sum # Go module dependencies' checksums and hash keys.
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
|
|
|
@ -2,17 +2,18 @@
|
|||
|
||||
<br>
|
||||
|
||||
**sponge** 是一个强大的 `Go` 开发框架,其核心理念是通过解析 `JSON`、`SQL` 或 `Protobuf` 文件逆向生成模块化的代码,这些代码可以灵活、无缝地组合成多种类型的完整后端服务(类似海绵细胞的特性,打散的海绵细胞能自动重新组合成新的海绵)。sponge 提供一站式项目开发解决方案,涵盖代码生成、开发、测试、API 文档生成和部署,大幅提升开发效率,降低开发难度,实现以"低代码"方式构建高质量项目。
|
||||
**sponge** 是一个强大的 `Go` 开发框架,其核心理念是通过解析 `JSON`、`SQL` 或 `Protobuf` 文件逆向生成模块化的代码,这些代码可以灵活、无缝地组合成多种类型的完整后端服务(`类似海绵细胞的特性,打散的海绵细胞能自动重新组合成新的海绵`)。sponge 提供一站式项目开发解决方案,涵盖代码生成、开发、测试、API 文档生成和部署,大幅提升开发效率,降低开发难度,实现以"低代码"方式构建高质量项目。
|
||||
|
||||
<br>
|
||||
|
||||
### 适用场景
|
||||
|
||||
sponge 适用于快速开发各种高性能后端服务,包括但不限于:
|
||||
- `Web` 服务;
|
||||
- `Web` 服务 (gin);
|
||||
- `gRPC` 服务;
|
||||
- `HTTP+gRPC` 混合服务;
|
||||
- `gRPC Gateway API` 服务。
|
||||
- `gRPC Gateway API` 服务;
|
||||
- 云原生微服务;
|
||||
|
||||
此外,开发者还可以通过自定义模板,生成满足业务需求的各类代码。
|
||||
|
||||
|
@ -39,6 +40,8 @@ sponge 适用于快速开发各种高性能后端服务,包括但不限于:
|
|||
- 测试代码;
|
||||
- 构建和部署脚本等。
|
||||
|
||||
4. **在页面生成代码,简单易用**
|
||||
|
||||
<br>
|
||||
|
||||
### 快速开始
|
||||
|
@ -65,62 +68,22 @@ sponge 适用于快速开发各种高性能后端服务,包括但不限于:
|
|||
|
||||
<br>
|
||||
|
||||
### 生成代码的框架图
|
||||
|
||||
sponge 支持基于自带模板和自定义模板两种方式生成你的项目所需的代码,下面是两种生成代码的框架图。
|
||||
|
||||
1. sponge 基于自带模板生成代码框架如下图所示,共有 sql 和 protobuf 两种方式生成代码。
|
||||
|
||||
<p align="center">
|
||||
<img width="1500px" src="https://raw.githubusercontent.com/go-dev-frame/sponge/main/assets/sponge-framework.png">
|
||||
</p>
|
||||
|
||||
<br>
|
||||
|
||||
2. sponge 基于自定义模板生成代码框架如下图所示,共有 json、sql、protobuf 三种方式生成代码。
|
||||
|
||||
<p align="center">
|
||||
<img width="1200px" src="https://raw.githubusercontent.com/go-dev-frame/sponge/main/assets/template-framework.png">
|
||||
</p>
|
||||
|
||||
<br>
|
||||
|
||||
### 微服务框架
|
||||
|
||||
sponge 支持创建 6 种类型的后端服务,均为微服务架构。下图展示了典型的微服务分层结构,具备高性能、高扩展性,并内置常用的服务治理功能。
|
||||
|
||||
<p align="center">
|
||||
<img width="1000px" src="https://raw.githubusercontent.com/go-dev-frame/sponge/main/assets/microservices-framework.png">
|
||||
</p>
|
||||
|
||||
<br>
|
||||
|
||||
创建的http和grpc服务代码的性能测试: 50个并发,总共100万个请求。
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
点击查看[**测试代码**](https://github.com/zhufuyi/microservices_framework_benchmark)。
|
||||
|
||||
<br>
|
||||
|
||||
### 主要功能
|
||||
|
||||
sponge包含丰富的组件(按需使用):
|
||||
sponge 内置了丰富的功能(按需使用):
|
||||
|
||||
- Web 框架 [gin](https://github.com/gin-gonic/gin)
|
||||
- RPC 框架 [grpc](https://github.com/grpc/grpc-go)
|
||||
- 配置解析 [viper](https://github.com/spf13/viper)
|
||||
- 日志 [zap](https://github.com/uber-go/zap)
|
||||
- 数据库组件 [gorm](https://github.com/go-gorm/gorm), [mongo-go-driver](https://github.com/mongodb/mongo-go-driver)
|
||||
- 缓存组件 [go-redis](https://github.com/go-redis/redis), [ristretto](https://github.com/dgraph-io/ristretto)
|
||||
- ORM 框架 [gorm](https://github.com/go-gorm/gorm), [mongo-go-driver](https://github.com/mongodb/mongo-go-driver)
|
||||
- 缓存 [go-redis](https://github.com/go-redis/redis), [ristretto](https://github.com/dgraph-io/ristretto)
|
||||
- 自动化api文档 [swagger](https://github.com/swaggo/swag), [protoc-gen-openapiv2](https://github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2)
|
||||
- 鉴权 [jwt](https://github.com/golang-jwt/jwt)
|
||||
- 校验 [validator](https://github.com/go-playground/validator)
|
||||
- Websocket [gorilla/websocket](https://github.com/gorilla/websocket)
|
||||
- 定时任务 [cron](https://github.com/robfig/cron)
|
||||
- 消息队列组件 [rabbitmq](https://github.com/rabbitmq/amqp091-go), [kafka](https://github.com/IBM/sarama)
|
||||
- 消息队列 [rabbitmq](https://github.com/rabbitmq/amqp091-go), [kafka](https://github.com/IBM/sarama)
|
||||
- 分布式事务管理器 [dtm](https://github.com/dtm-labs/dtm)
|
||||
- 分布式锁 [dlock](https://github.com/go-dev-frame/sponge/tree/main/pkg/dlock)
|
||||
- 自适应限流 [ratelimit](https://github.com/go-dev-frame/sponge/tree/main/pkg/shield/ratelimit)
|
||||
|
@ -138,60 +101,102 @@ sponge包含丰富的组件(按需使用):
|
|||
|
||||
<br>
|
||||
|
||||
### 生成代码的框架
|
||||
|
||||
sponge 支持基于自带模板和自定义模板两种方式生成你的项目所需的代码,下面是两种生成代码的框架图。
|
||||
|
||||
1. sponge 基于自带模板生成代码框架如下图所示,支持 sql 和 protobuf 两种方式。
|
||||
|
||||
<p align="center">
|
||||
<img width="1500px" src="https://raw.githubusercontent.com/go-dev-frame/sponge/main/assets/sponge-framework.png">
|
||||
</p>
|
||||
|
||||
<br>
|
||||
|
||||
2. sponge 基于自定义模板生成代码框架如下图所示,支持 json、sql、protobuf 三种方式。
|
||||
|
||||
<p align="center">
|
||||
<img width="1200px" src="https://raw.githubusercontent.com/go-dev-frame/sponge/main/assets/template-framework.png">
|
||||
</p>
|
||||
|
||||
<br>
|
||||
|
||||
### 微服务框架
|
||||
|
||||
sponge 创建的 6 种类型的后端服务中有 5 种属于微服务架构。下图展示了典型的微服务分层结构,具备高性能、高扩展性,并内置常用的服务治理功能。
|
||||
|
||||
<p align="center">
|
||||
<img width="1000px" src="https://raw.githubusercontent.com/go-dev-frame/sponge/main/assets/microservices-framework.png">
|
||||
</p>
|
||||
|
||||
<br>
|
||||
|
||||
创建的http和grpc服务代码的性能测试: 50个并发,总共100万个请求。
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
点击查看[**测试代码**](https://github.com/zhufuyi/microservices_framework_benchmark)。
|
||||
|
||||
<br>
|
||||
|
||||
### 目录结构
|
||||
|
||||
生成的服务代码目录结构遵循 [project-layout](https://github.com/golang-standards/project-layout)。
|
||||
sponge 创建的服务代码目录结构遵循 [project-layout](https://github.com/golang-standards/project-layout)。
|
||||
|
||||
这是生成的`单体应用单体仓库(monolith)`或`微服务多仓库(multi-repo)`代码目录结构:
|
||||
sponge 支持创建 `单体应用单体仓库(monolith)`、`微服务多仓库(multi-repo)`、`微服务单体仓库(mono-repo)`三种类型的项目代码结构。
|
||||
|
||||
1. 创建`单体应用单体仓库(monolith)`或`微服务多仓库(multi-repo)`代码目录结构如下:
|
||||
|
||||
```bash
|
||||
.
|
||||
├── api # protobuf文件和生成的*pb.go目录
|
||||
├── assets # 其他与资源库一起使用的资产(图片、logo等)目录
|
||||
├── cmd # 程序入口目录
|
||||
├── configs # 配置文件的目录
|
||||
├── deployments # 裸机、docker、k8s部署脚本目录
|
||||
├── docs # 设计文档和界面文档目录
|
||||
├── internal # 业务逻辑代码目录
|
||||
│ ├── cache # 基于业务包装的缓存目录
|
||||
│ ├── config # Go结构的配置文件目录
|
||||
│ ├── dao # 数据访问目录
|
||||
│ ├── database # 数据库目录
|
||||
│ ├── ecode # 自定义业务错误代码目录
|
||||
│ ├── handler # http的业务功能实现目录
|
||||
│ ├── model # 数据库模型目录
|
||||
│ ├── routers # http路由目录
|
||||
│ ├── rpcclient # 连接grpc服务的客户端目录
|
||||
│ ├── server # 服务入口,包括http、grpc等
|
||||
│ ├── service # grpc的业务功能实现目录
|
||||
│ └── types # http的请求和响应类型目录
|
||||
├── pkg # 外部应用程序可以使用的库目录
|
||||
├── scripts # 执行脚本目录
|
||||
├── test # 额外的外部测试程序和测试数据
|
||||
├── third_party # 依赖第三方protobuf文件或其他工具的目录
|
||||
├── Makefile # 开发、测试、部署相关的命令集合
|
||||
├── go.mod # go 模块依赖关系和版本控制文件
|
||||
└── go.sum # go 模块依赖项的密钥和校验文件
|
||||
.
|
||||
├── api # protobuf文件和生成的*pb.go目录
|
||||
├── assets # 其他与资源库一起使用的资产(图片、logo等)目录
|
||||
├── cmd # 程序入口目录
|
||||
├── configs # 配置文件的目录
|
||||
├── deployments # 裸机、docker、k8s部署脚本目录
|
||||
├── docs # 设计文档和界面文档目录
|
||||
├── internal # 业务逻辑代码目录
|
||||
│ ├── cache # 基于业务包装的缓存目录
|
||||
│ ├── config # Go结构的配置文件目录
|
||||
│ ├── dao # 数据访问目录
|
||||
│ ├── database # 数据库目录
|
||||
│ ├── ecode # 自定义业务错误代码目录
|
||||
│ ├── handler # http的业务功能实现目录
|
||||
│ ├── model # 数据库模型目录
|
||||
│ ├── routers # http路由目录
|
||||
│ ├── rpcclient # 连接grpc服务的客户端目录
|
||||
│ ├── server # 服务入口,包括http、grpc等
|
||||
│ ├── service # grpc的业务功能实现目录
|
||||
│ └── types # http的请求和响应类型目录
|
||||
├── pkg # 外部应用程序可以使用的库目录
|
||||
├── scripts # 执行脚本目录
|
||||
├── test # 额外的外部测试程序和测试数据
|
||||
├── third_party # 依赖第三方protobuf文件或其他工具的目录
|
||||
├── Makefile # 开发、测试、部署相关的命令集合
|
||||
├── go.mod # go 模块依赖关系和版本控制文件
|
||||
└── go.sum # go 模块依赖项的密钥和校验文件
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
这是生成的`微服务单体仓库(mono-repo)`代码目录结构(也就是大仓库代码目录结构):
|
||||
2. 创建`微服务单体仓库(mono-repo)`代码目录结构(大仓库代码目录结构)如下:
|
||||
|
||||
```bash
|
||||
.
|
||||
├── api
|
||||
│ ├── server1 # 服务1的protobuf文件和生成的*pb.go目录
|
||||
│ ├── server2 # 服务2的protobuf文件和生成的*pb.go目录
|
||||
│ ├── server3 # 服务3的protobuf文件和生成的*pb.go目录
|
||||
│ └── ...
|
||||
├── server1 # 服务1的代码目录,与微服务多仓库(multi-repo)目录结构基本一样
|
||||
├── server2 # 服务2的代码目录,与微服务多仓库(multi-repo)目录结构基本一样
|
||||
├── server3 # 服务3的代码目录,与微服务多仓库(multi-repo)目录结构基本一样
|
||||
├── ...
|
||||
├── third_party # 依赖的第三方protobuf文件
|
||||
├── go.mod # go 模块依赖关系和版本控制文件
|
||||
└── go.sum # go 模块依赖项的密钥和校验和文件
|
||||
.
|
||||
├── api
|
||||
│ ├── server1 # 服务1的protobuf文件和生成的*pb.go目录
|
||||
│ ├── server2 # 服务2的protobuf文件和生成的*pb.go目录
|
||||
│ ├── server3 # 服务3的protobuf文件和生成的*pb.go目录
|
||||
│ └── ...
|
||||
├── server1 # 服务1的代码目录,与微服务多仓库(multi-repo)目录结构基本一样
|
||||
├── server2 # 服务2的代码目录,与微服务多仓库(multi-repo)目录结构基本一样
|
||||
├── server3 # 服务3的代码目录,与微服务多仓库(multi-repo)目录结构基本一样
|
||||
├── ...
|
||||
├── third_party # 依赖的第三方protobuf文件
|
||||
├── go.mod # go 模块依赖关系和版本控制文件
|
||||
└── go.sum # go 模块依赖项的密钥和校验和文件
|
||||
```
|
||||
|
||||
<br>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Rich examples of sponge usage view repository [**https://github.com/go-dev-frame/sponge_examples**](https://github.com/go-dev-frame/sponge_examples)
|
|
@ -28,7 +28,7 @@ func main() {
|
|||
}
|
||||
defer redisCli.Close()
|
||||
|
||||
locker, err := NewRedisLock(redisCli, "test_lock")
|
||||
locker, err := dlock.NewRedisLock(redisCli, "test_lock")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue