Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/v2.3.0 #2296

Merged
merged 8 commits into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/gf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
services:
# Redis backend server.
redis:
image : loads/redis:latest
image : loads/redis:7.0
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:

# MSSQL backend server.
mssql:
image: loads/mssqldocker:latest
image: loads/mssqldocker:14.0.3391.2
env:
ACCEPT_EULA: Y
SA_PASSWORD: LoremIpsum86
Expand All @@ -94,25 +94,25 @@ jobs:
--health-retries 10

# ClickHouse backend server.
# docker run -d --name clickhouse -p 9000:9000 -p 8123:8123 -p 9001:9001 loads/clickhouse-server:latest
# docker run -d --name clickhouse -p 9000:9000 -p 8123:8123 -p 9001:9001 loads/clickhouse-server:22.1.3.7
clickhouse-server:
image: loads/clickhouse-server:latest
image: loads/clickhouse-server:22.1.3.7
ports:
- 9000:9000
- 8123:8123
- 9001:9001

# Polaris backend server.
polaris:
image: loads/polaris-server-standalone:latest
image: loads/polaris-server-standalone:1.11.2
ports:
- 8090:8090
- 8091:8091
- 8093:8093

# Oracle 11g server
oracle-server:
image: loads/oracle-xe-11g-r2:latest
image: loads/oracle-xe-11g-r2:11.2.0
env:
ORACLE_ALLOW_REMOTE: true
ORACLE_SID: XE
Expand Down
3 changes: 0 additions & 3 deletions cmd/gf/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@ require (

require (
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/clbanning/mxj/v2 v2.5.5 // indirect
github.com/denisenkom/go-mssqldb v0.11.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/glebarez/go-sqlite v1.17.3 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-redis/redis/v8 v8.11.5 // indirect
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect
github.com/google/uuid v1.3.0 // indirect
Expand Down
75 changes: 1 addition & 74 deletions cmd/gf/go.sum

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions cmd/gf/internal/cmd/cmd_fix.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,16 @@ func (c cFix) doFix() (err error) {
// doFixV23 fixes code when upgrading to GoFrame v2.3.
func (c cFix) doFixV23(version string) error {
replaceFunc := func(path, content string) string {
// gdb.TX from struct to interface.
content = gstr.Replace(content, "*gdb.TX", "gdb.TX")
// function name changes for package gtcp/gudp.
if gstr.Contains(content, "/gf/v2/net/gtcp") || gstr.Contains(content, "/gf/v2/net/gudp") {
content = gstr.ReplaceByMap(content, g.MapStrStr{
".SetSendDeadline": ".SetDeadlineSend",
".SetReceiveDeadline": ".SetDeadlineRecv",
".SetReceiveBufferWait": ".SetBufferWaitRecv",
})
}
return content
}
return gfile.ReplaceDirFunc(replaceFunc, ".", "*.go", true)
Expand Down
2 changes: 1 addition & 1 deletion cmd/gf/internal/consts/consts_gen_dao_template_dao.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions container/gpool/gpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ func (p *Pool) Put(value interface{}) error {
return nil
}

// MustPut puts an item to pool, it panics if any error occurs.
func (p *Pool) MustPut(value interface{}) {
if err := p.Put(value); err != nil {
panic(err)
}
}

// Clear clears pool, which means it will remove all items from pool.
func (p *Pool) Clear() {
if p.ExpireFunc != nil {
Expand Down
25 changes: 13 additions & 12 deletions container/gpool/gpool_z_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func ExamplePool_Put() {
// conn.(*DBConn).Conn.QueryContext(context.Background(), "select * from user")

// put back conn
dbConnPool.Put(conn)
dbConnPool.MustPut(conn)

fmt.Println(conn.(*DBConn).Limit)

Expand All @@ -88,8 +88,8 @@ func ExamplePool_Clear() {
})

conn, _ := dbConnPool.Get()
dbConnPool.Put(conn)
dbConnPool.Put(conn)
dbConnPool.MustPut(conn)
dbConnPool.MustPut(conn)
fmt.Println(dbConnPool.Size())
dbConnPool.Clear()
fmt.Println(dbConnPool.Size())
Expand Down Expand Up @@ -144,8 +144,8 @@ func ExamplePool_Size() {

conn, _ := dbConnPool.Get()
fmt.Println(dbConnPool.Size())
dbConnPool.Put(conn)
dbConnPool.Put(conn)
dbConnPool.MustPut(conn)
dbConnPool.MustPut(conn)
fmt.Println(dbConnPool.Size())

// Output:
Expand All @@ -158,21 +158,22 @@ func ExamplePool_Close() {
Conn *sql.Conn
Limit int
}

dbConnPool := gpool.New(time.Hour,
func() (interface{}, error) {
var (
newFunc = func() (interface{}, error) {
dbConn := new(DBConn)
dbConn.Limit = 10
return dbConn, nil
},
func(i interface{}) {
}
closeFunc = func(i interface{}) {
fmt.Println("Close The Pool")
// sample : close db conn
// i.(DBConn).Conn.Close()
})
}
)
dbConnPool := gpool.New(time.Hour, newFunc, closeFunc)

conn, _ := dbConnPool.Get()
dbConnPool.Put(conn)
dbConnPool.MustPut(conn)

dbConnPool.Close()

Expand Down
Loading