github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/pkg/gluetikv/glue.go (about) 1 // Copyright 2020 PingCAP, Inc. Licensed under Apache-2.0. 2 3 package gluetikv 4 5 import ( 6 "context" 7 8 "github.com/pingcap/tidb/config" 9 "github.com/pingcap/tidb/domain" 10 "github.com/pingcap/tidb/kv" 11 "github.com/pingcap/tidb/store/driver" 12 pd "github.com/tikv/pd/client" 13 14 "github.com/pingcap/br/pkg/glue" 15 "github.com/pingcap/br/pkg/summary" 16 "github.com/pingcap/br/pkg/utils" 17 "github.com/pingcap/br/pkg/version/build" 18 ) 19 20 // Glue is an implementation of glue.Glue that accesses only TiKV without TiDB. 21 type Glue struct{} 22 23 // GetDomain implements glue.Glue. 24 func (Glue) GetDomain(store kv.Storage) (*domain.Domain, error) { 25 return nil, nil 26 } 27 28 // CreateSession implements glue.Glue. 29 func (Glue) CreateSession(store kv.Storage) (glue.Session, error) { 30 return nil, nil 31 } 32 33 // Open implements glue.Glue. 34 func (Glue) Open(path string, option pd.SecurityOption) (kv.Storage, error) { 35 if option.CAPath != "" { 36 conf := config.GetGlobalConfig() 37 conf.Security.ClusterSSLCA = option.CAPath 38 conf.Security.ClusterSSLCert = option.CertPath 39 conf.Security.ClusterSSLKey = option.KeyPath 40 config.StoreGlobalConfig(conf) 41 } 42 return driver.TiKVDriver{}.Open(path) 43 } 44 45 // OwnsStorage implements glue.Glue. 46 func (Glue) OwnsStorage() bool { 47 return true 48 } 49 50 // StartProgress implements glue.Glue. 51 func (Glue) StartProgress(ctx context.Context, cmdName string, total int64, redirectLog bool) glue.Progress { 52 return utils.StartProgress(ctx, cmdName, total, redirectLog, nil) 53 } 54 55 // Record implements glue.Glue. 56 func (Glue) Record(name string, val uint64) { 57 summary.CollectSuccessUnit(name, 1, val) 58 } 59 60 // GetVersion implements glue.Glue. 61 func (Glue) GetVersion() string { 62 return "BR\n" + build.Info() 63 }