improve the NewEngineGroup interface
This commit is contained in:
parent
7378a2f1d0
commit
e5e4d6078e
|
@ -5,8 +5,6 @@
|
||||||
package xorm
|
package xorm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/go-xorm/core"
|
"github.com/go-xorm/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,9 +25,8 @@ func NewEngineGroup(args1 interface{}, args2 interface{}, policies ...GroupPolic
|
||||||
}
|
}
|
||||||
|
|
||||||
driverName, ok1 := args1.(string)
|
driverName, ok1 := args1.(string)
|
||||||
dataSourceNames, ok2 := args2.(string)
|
conns, ok2 := args2.([]string)
|
||||||
if ok1 && ok2 {
|
if ok1 && ok2 {
|
||||||
conns := strings.Split(dataSourceNames, ";")
|
|
||||||
engines := make([]*Engine, len(conns))
|
engines := make([]*Engine, len(conns))
|
||||||
for i, conn := range conns {
|
for i, conn := range conns {
|
||||||
engine, err := NewEngine(driverName, conn)
|
engine, err := NewEngine(driverName, conn)
|
||||||
|
|
|
@ -26,6 +26,7 @@ var (
|
||||||
mapType = flag.String("map_type", "snake", "indicate the name mapping")
|
mapType = flag.String("map_type", "snake", "indicate the name mapping")
|
||||||
cache = flag.Bool("cache", false, "if enable cache")
|
cache = flag.Bool("cache", false, "if enable cache")
|
||||||
cluster = flag.Bool("cluster", false, "if this is a cluster")
|
cluster = flag.Bool("cluster", false, "if this is a cluster")
|
||||||
|
splitter = flag.String("splitter", ";", "the splitter on connstr for cluster")
|
||||||
)
|
)
|
||||||
|
|
||||||
func createEngine(dbType, connStr string) error {
|
func createEngine(dbType, connStr string) error {
|
||||||
|
@ -36,7 +37,7 @@ func createEngine(dbType, connStr string) error {
|
||||||
testEngine, err = NewEngine(dbType, connStr)
|
testEngine, err = NewEngine(dbType, connStr)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
testEngine, err = NewEngineGroup(dbType, connStr)
|
testEngine, err = NewEngineGroup(dbType, strings.Split(connStr, *splitter))
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue