From d28790748d676c4545d86b63d2d602f7ee029ded Mon Sep 17 00:00:00 2001 From: lance6716 Date: Thu, 20 Aug 2020 15:43:42 +0800 Subject: [PATCH] export GetDSN in dependency usage (#138) --- v4/export/config.go | 3 ++- v4/export/dump.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/v4/export/config.go b/v4/export/config.go index 87f9d6e4..3fc93338 100644 --- a/v4/export/config.go +++ b/v4/export/config.go @@ -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" diff --git a/v4/export/dump.go b/v4/export/dump.go index bd150987..bf478807 100755 --- a/v4/export/dump.go +++ b/v4/export/dump.go @@ -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) } @@ -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