Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Commit

Permalink
export GetDSN in dependency usage (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
lance6716 authored Aug 20, 2020
1 parent 26975af commit d287907
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion v4/export/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ func DefaultConfig() *Config {
}
}

func (conf *Config) getDSN(db string) string {
// GetDSN generates DSN from Config
func (conf *Config) GetDSN(db string) string {
dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4", conf.User, conf.Password, conf.Host, conf.Port, db)
if len(conf.Security.CAPath) > 0 {
dsn += "&tls=dumpling-tls-target"
Expand Down
4 changes: 2 additions & 2 deletions v4/export/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func Dump(pCtx context.Context, conf *Config) (err error) {
}
}()

pool, err := sql.Open("mysql", conf.getDSN(""))
pool, err := sql.Open("mysql", conf.GetDSN(""))
if err != nil {
return withStack(err)
}
Expand Down Expand Up @@ -107,7 +107,7 @@ func Dump(pCtx context.Context, conf *Config) (err error) {
"After dumping: run sql `update mysql.tidb set VARIABLE_VALUE = '10m' where VARIABLE_NAME = 'tikv_gc_life_time';` in tidb.\n")
}

if newPool, err := resetDBWithSessionParams(pool, conf.getDSN(""), conf.SessionParams); err != nil {
if newPool, err := resetDBWithSessionParams(pool, conf.GetDSN(""), conf.SessionParams); err != nil {
return withStack(err)
} else {
pool = newPool
Expand Down

0 comments on commit d287907

Please sign in to comment.