Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zhufuyi committed Apr 13, 2024
1 parent 6421490 commit 9e1682f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 14 deletions.
1 change: 1 addition & 0 deletions .github/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

- Add generate grpc+http service code
- Add generate service+handler CRUD code
- Fix known bugs
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,24 @@ Sponge is mainly based on `SQL` and `Protobuf` two ways to generate code, each w

### Microservice framework

Sponge is essentially a microservice framework that includes code generation capabilities. The microservice framework is shown in the following figure, which is a typical microservice hierarchical structure, with high performance, high scalability, contains commonly used service governance features, you can easily replace or add their own service governance features.
Sponge is also a microservices framework, the framework diagram is shown below, which is a typical microservice hierarchical structure, with high performance, high scalability, contains commonly used service governance features, you can easily replace or add their own service governance features.

<p align="center">
<img width="1000px" src="https://raw.githubusercontent.com/zhufuyi/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.

![http-server](https://raw.githubusercontent.com/zhufuyi/microservices_framework_benchmark/main/test/assets/http-server.png)

![grpc-server](https://raw.githubusercontent.com/zhufuyi/microservices_framework_benchmark/main/test/assets/grpc-server.png)

Click to view the [**test code**](https://github.com/zhufuyi/microservices_framework_benchmark).

<br>

### Key Features

- Web framework [gin](https://github.com/gin-gonic/gin)
Expand Down Expand Up @@ -83,7 +93,7 @@ Sponge is essentially a microservice framework that includes code generation cap

### Project Code Directory Structure

The project code directory structure created by sponge follows the [project-layout](https://github.com/golang-standards/project-layout) convention and is structured as follows:
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)`.

```bash
.
Expand Down Expand Up @@ -120,7 +130,7 @@ The project code directory structure created by sponge follows the [project-layo

#### Installation sponge

sponge can be installed on Windows, macOS, Linux and Docker environments. Click here for [instructions on installing sponge](https://github.com/zhufuyi/sponge/blob/main/assets/install-en.md).
Sponge can be installed on Windows, macOS, Linux and Docker environments. Click here for [instructions on installing sponge](https://github.com/zhufuyi/sponge/blob/main/assets/install-en.md).

#### Starting UI service

Expand All @@ -144,7 +154,7 @@ Detailed instructions for operating, configuring, and deploying a project using

### Examples of use

#### Examples of creating a service using sponge
#### Examples of create services

- [Create **web** service based on **sql** (including CRUD)](https://github.com/zhufuyi/sponge_examples/tree/main/1_web-gin-CRUD)
- [Create **grpc** service based on **sql** (including CRUD)](https://github.com/zhufuyi/sponge_examples/tree/main/2_micro-grpc-CRUD)
Expand All @@ -153,7 +163,7 @@ Detailed instructions for operating, configuring, and deploying a project using
- [Create **grpc gateway** service based on **protobuf**](https://github.com/zhufuyi/sponge_examples/tree/main/5_micro-gin-rpc-gateway)
- [Create **grpc+http** service based on **protobuf**](https://github.com/zhufuyi/sponge_examples/tree/main/a_micro-grpc-http-protobuf)

#### Examples of developing a complete project using sponge
#### Examples of develop complete project

- [Simple community web backend service](https://github.com/zhufuyi/sponge_examples/tree/main/7_community-single)
- [Simple community web service broken down into microservice](https://github.com/zhufuyi/sponge_examples/tree/main/8_community-cluster)
Expand Down
22 changes: 16 additions & 6 deletions assets/readme-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

<br>

[sponge](https://github.com/zhufuyi/sponge) 是一个集成了 `自动生成代码``Gin和GRPC` 的强大的开发框架。sponge拥有丰富的生成代码命令,生成不同的功能代码可以组合成完整的服务(类似人为打散的海绵细胞可以自动重组成一个新的海绵)。从开发、测试、api文档到部署一站式项目开发,大幅提高了开发效率和降低了开发难度,实现"低代码方式"开发项目
[sponge](https://github.com/zhufuyi/sponge) 是一个集成了 `自动生成代码``Gin和GRPC` 的强大的开发框架。sponge拥有丰富的生成代码命令,生成不同的功能代码可以组合成完整的服务(类似人为打散的海绵细胞可以自动重组成一个新的海绵)。从开发、测试、api文档到部署一站式项目开发,大幅提高了开发效率和降低了开发难度,实现"低代码方式"进行开发项目

<br>

如果开发只有CRUD api接口的web或微服务,不需要编写任何go代码就可以编译并部署到linux服务器、docker、k8s上,只需要连接到数据库(mysql、mongodb、postgresql、tidb、sqlite)就可以一键自动生成完整的后端服务go代码。
如果开发只有CRUD api的web或微服务,不需要编写任何go代码就可以编译并部署到linux服务器、docker、k8s上,只需要连接到数据库(mysql、mongodb、postgresql、tidb、sqlite)就可以一键自动生成完整的后端服务go代码。

如果开发通用的web或微服务,只需聚焦`在数据库定义表``在proto文件定义api描述信息``在生成的模板文件填写业务逻辑代码`三个核心部分,其他go代码都由sponge自动生成。

<br>

### 生成代码框架

sponge主要基于`SQL``Protobuf`两种方式生成代码,每种方式拥有生成不同用途的代码。其中`SQL`支持数据库**mysql****mongodb****postgresql****tidb****sqlite**
sponge主要基于`SQL``Protobuf`两种方式生成代码,每种方式生成不同用途的代码。其中`SQL`支持数据库**mysql****mongodb****postgresql****tidb****sqlite**

#### 生成代码的框架图

Expand All @@ -34,14 +34,24 @@ sponge主要基于`SQL`和`Protobuf`两种方式生成代码,每种方式拥

### 微服务框架

sponge本质是一个包含了自动生成代码功能的微服务框架,微服务框架如下图所示,这是典型的微服务分层结构,具有高性能,高扩展性,包含了常用的服务治理功能,可以很方便替换或添加自己的服务治理功能。
sponge也是一个微服务框架,框架图如下图所示,这是典型的微服务分层结构,具有高性能,高扩展性,包含了常用的服务治理功能,可以很方便替换或添加自己的服务治理功能。

<p align="center">
<img width="1000px" src="https://raw.githubusercontent.com/zhufuyi/sponge/main/assets/microservices-framework.png">
</p>

<br>

创建的http和grpc服务代码的性能测试: 50个并发,总共100万个请求。

![http-server](https://raw.githubusercontent.com/zhufuyi/microservices_framework_benchmark/main/test/assets/http-server.png)

![grpc-server](https://raw.githubusercontent.com/zhufuyi/microservices_framework_benchmark/main/test/assets/grpc-server.png)

点击查看[**测试代码**](https://github.com/zhufuyi/microservices_framework_benchmark)

<br>

### 主要功能

sponge包含丰富的组件(按需使用):
Expand All @@ -53,7 +63,7 @@ sponge包含丰富的组件(按需使用):
- 日志 [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)
- 自动化api接口文档 [swagger](https://github.com/swaggo/swag), [protoc-gen-openapiv2](https://github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2)
- 自动化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)
- 消息组件 [rabbitmq](https://github.com/rabbitmq/amqp091-go)
Expand All @@ -72,7 +82,7 @@ sponge包含丰富的组件(按需使用):

### 目录结构

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

```bash
.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ import (
func Test_service_{{.LowerName}}_methods(t *testing.T) {
conn := getRPCClientConnForTest()
cli := serverNameExampleV1.New{{.Name}}Client(conn)
ctx := context.Background()
ctx, _ := context.WithTimeout(context.Background(), time.Second*30)
tests := []struct {
name string
Expand Down
5 changes: 3 additions & 2 deletions internal/server/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ func TestHTTPServerMock(t *testing.T) {
addr := fmt.Sprintf(":%d", port)

o := defaultHTTPOptions()
if o.isProd {
gin.SetMode(gin.ReleaseMode)
}
s := &httpServer{
addr: addr,
instance: &registry.ServiceInstance{},
Expand All @@ -85,8 +88,6 @@ func TestHTTPServerMock(t *testing.T) {
s.server = &http.Server{
Addr: addr,
Handler: http.NewServeMux(),
ReadTimeout: o.readTimeout,
WriteTimeout: o.writeTimeout,
MaxHeaderBytes: 1 << 20,
}

Expand Down

0 comments on commit 9e1682f

Please sign in to comment.