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