Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zhufuyi committed Feb 5, 2024
1 parent 61e8328 commit 948b3f0
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

</div>

[Sponge](https://github.com/zhufuyi/sponge) is a powerful golang productivity tool that integrates `automatic code generation`, `web and microservices frameworks`, `basic development framework`. sponge has a wealth of generating code commands, generating different functional code can be combined into a complete service (similar to the way that artificially broken sponge cells can automatically recombine into a new sponge). The code is decoupled and modularly designed, it is easy to build a complete project from development to deployment, so that you develop web or microservices project easily, golang can also be "low-code development".
**Sponge** is a basic development framework that integrates `code auto generation`, `gin and grpc`, sponge has a wealth of generating code commands, generating different functional code can be combined into a complete service (similar to the way that artificially broken sponge cells can automatically recombine into a new sponge). The code is decoupled and modularly designed, it is easy to build a complete project from development to deployment, so that you develop web or microservices project easily, Go can also be "low-code development".

<br>

Expand Down Expand Up @@ -47,7 +47,7 @@ sponge is mainly based on **SQL** and **Protobuf** two ways to generate code, ea

### Services framework

sponge generated microservice code framework is shown in the figure 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.
Sponge is essentially a microservice framework that includes code generation and deployment 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.

<p align="center">
<img width="1000px" src="https://raw.githubusercontent.com/zhufuyi/sponge/main/assets/microservices-framework.png">
Expand Down
2 changes: 1 addition & 1 deletion assets/install-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

下载protoc地址: [https://github.com/protocolbuffers/protobuf/releases/tag/v25.2](https://github.com/protocolbuffers/protobuf/releases/tag/v25.2)

> 要求v3.20以上版本,根据系统类型下载对应的 protoc 二进制文件,把 protoc 二进制文件移动到go二进制文件所在的目录。
> 根据系统类型下载对应的 protoc 二进制文件,把 protoc 二进制文件移动到go二进制文件所在的目录。
查看protoc版本: `protoc --version`

Expand Down
2 changes: 1 addition & 1 deletion assets/install-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Check go version: `go version`

Download protoc from: [https://github.com/protocolbuffers/protobuf/releases/tag/v25.2](https://github.com/protocolbuffers/protobuf/releases/tag/v25.2)

> Required version: v3.20 or above. Download the protoc binaries according to the system type, move the protoc binaries to the directory where the go binaries are located.
> Download the protoc binaries according to the system type, move the protoc binaries to the directory where the go binaries are located.
Check protoc version: `protoc --version`

Expand Down
7 changes: 5 additions & 2 deletions assets/readme-cn.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[sponge](https://github.com/zhufuyi/sponge) 是一个集成了`自动生成代码``web和微服务框架``基础开发框架`的golang生产力工具。sponge拥有丰富的生成代码命令,生成不同的功能代码可以组合成完整的服务(类似人为打散的海绵细胞可以自动重组成一个新的海绵)。代码解耦模块化设计,很容易构建出从开发到部署的完整工程项目,让你开发web或微服务项目轻而易举、事半功倍,golang也可以"低代码开发"。



[sponge](https://github.com/zhufuyi/sponge) 是一个集成了 `自动生成代码``gin和grpc` 的基础开发框架。sponge拥有丰富的生成代码命令,生成不同的功能代码可以组合成完整的服务(类似人为打散的海绵细胞可以自动重组成一个新的海绵)。代码解耦模块化设计,很容易构建出从开发到部署的完整工程项目,让你开发web或微服务项目轻而易举、事半功倍,使用go也可以"低代码开发"。

<br>

Expand Down Expand Up @@ -30,7 +33,7 @@ sponge主要基于**SQL**和**Protobuf**两种方式生成代码,每种方式

### 微服务框架

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

<p align="center">
<img width="1000px" src="https://raw.githubusercontent.com/zhufuyi/sponge/main/assets/microservices-framework.png">
Expand Down
6 changes: 4 additions & 2 deletions pkg/ggorm/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
### mysql
### ggorm

`mysql` library wrapped in [gorm](gorm.io/gorm), with added features such as tracer, paging queries, etc.
`ggorm` library wrapped in [gorm](gorm.io/gorm), with added features such as tracer, paging queries, etc.

Support `mysql`, `postgresql`, `tidb`, `clickhouse`, `sqlite`.

<br>

Expand Down
2 changes: 1 addition & 1 deletion pkg/ggorm/base_model.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mysql
package ggorm

import (
"reflect"
Expand Down
19 changes: 17 additions & 2 deletions pkg/ggorm/gorm.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package mysql is a library wrapped on top of gorm.io/gorm, with added features such as link tracing, paging queries, etc.
package mysql
// Package ggorm is a library wrapped on top of gorm.io/gorm, with added features such as link tracing, paging queries, etc.
package ggorm

import (
"database/sql"
Expand Down Expand Up @@ -100,6 +100,21 @@ func InitPostgresql(dsn string, opts ...Option) (*gorm.DB, error) {
return db, nil
}

// InitTidb init tidb
func InitTidb(dsn string, opts ...Option) (*gorm.DB, error) {
return InitMysql(dsn, opts...)
}

// InitClickhouse init clickhouse
//func InitClickhouse(dsn string, opts ...Option) (*gorm.DB, error) {
// return InitMysql(dsn, opts...)
//}

// InitSqlite init sqlite
//func InitSqlite(dsn string, opts ...Option) (*gorm.DB, error) {
// panic("not implemented")
//}

// gorm setting
func gormConfig(o *options) *gorm.Config {
config := &gorm.Config{
Expand Down
2 changes: 1 addition & 1 deletion pkg/ggorm/gormLogger.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mysql
package ggorm

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion pkg/ggorm/gormLogger_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mysql
package ggorm

import (
"context"
Expand Down
13 changes: 12 additions & 1 deletion pkg/ggorm/gorm_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mysql
package ggorm

import (
"fmt"
Expand All @@ -21,6 +21,17 @@ func TestInitMysql(t *testing.T) {
t.Logf("%+v", db.Name())
}

func TestInitTidb(t *testing.T) {
db, err := InitTidb(dsn)
if err != nil {
// ignore test error about not being able to connect to real tidb
t.Logf(fmt.Sprintf("connect to mysql failed, err=%v, dsn=%s", err, dsn))
return
}

t.Logf("%+v", db.Name())
}

func TestInitPostgresql(t *testing.T) {
dsn = "host=192.168.3.37 user=root password=123456 dbname=account port=5432 sslmode=disable TimeZone=Asia/Shanghai"
db, err := InitPostgresql(dsn, WithEnableTrace())
Expand Down
2 changes: 1 addition & 1 deletion pkg/ggorm/option.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mysql
package ggorm

import (
"time"
Expand Down

0 comments on commit 948b3f0

Please sign in to comment.