mirror of
https://gitee.com/johng/gf
synced 2026-06-06 16:21:40 +08:00
add ci for golang v1.14
This commit is contained in:
18
.example/database/gdb/mysql/gdb_reconnect.go
Normal file
18
.example/database/gdb/mysql/gdb_reconnect.go
Normal file
@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
db := g.DB()
|
||||
db.SetDebug(true)
|
||||
for {
|
||||
r, err := db.Table("user").All()
|
||||
fmt.Println(err)
|
||||
fmt.Println(r)
|
||||
time.Sleep(time.Second * 10)
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,7 @@ go:
|
||||
- "1.11.x"
|
||||
- "1.12.x"
|
||||
- "1.13.x"
|
||||
- "1.14.x"
|
||||
|
||||
branches:
|
||||
only:
|
||||
|
||||
@ -172,7 +172,7 @@ const (
|
||||
gINSERT_OPTION_SAVE = 2
|
||||
gINSERT_OPTION_IGNORE = 3
|
||||
gDEFAULT_BATCH_NUM = 10 // Per count for batch insert/replace/save
|
||||
gDEFAULT_CONN_MAX_LIFE_TIME = 30 // Max life time for per connection in pool.
|
||||
gDEFAULT_CONN_MAX_LIFE_TIME = 30 // Max life time for per connection in pool in seconds.
|
||||
)
|
||||
|
||||
var (
|
||||
@ -197,12 +197,13 @@ func New(name ...string) (db DB, err error) {
|
||||
if _, ok := configs.config[group]; ok {
|
||||
if node, err := getConfigNodeByGroup(group, true); err == nil {
|
||||
base := &dbBase{
|
||||
group: group,
|
||||
debug: gtype.NewBool(),
|
||||
cache: gcache.New(),
|
||||
schema: gtype.NewString(),
|
||||
logger: glog.New(),
|
||||
prefix: node.Prefix,
|
||||
group: group,
|
||||
debug: gtype.NewBool(),
|
||||
cache: gcache.New(),
|
||||
schema: gtype.NewString(),
|
||||
logger: glog.New(),
|
||||
prefix: node.Prefix,
|
||||
// Default max connection life time if user does not configure.
|
||||
maxConnLifetime: gDEFAULT_CONN_MAX_LIFE_TIME,
|
||||
}
|
||||
switch node.Type {
|
||||
@ -246,8 +247,8 @@ func Instance(name ...string) (db DB, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// getConfigNodeByGroup calculates and returns a configuration node of given group.
|
||||
// It calculates the value internally using weight algorithm for load balance.
|
||||
// getConfigNodeByGroup calculates and returns a configuration node of given group. It
|
||||
// calculates the value internally using weight algorithm for load balance.
|
||||
//
|
||||
// The parameter <master> specifies whether retrieving a master node, or else a slave node
|
||||
// if master-slave configured.
|
||||
|
||||
Reference in New Issue
Block a user