diff --git a/go.mod b/go.mod index dd96d1837..0429a8833 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module github.com/tikv/client-go/v2 go 1.21 +replace github.com/tikv/pd/client v0.0.0-20230724080549-de985b8e0afc => github.com/JmPotato/pd/client v0.0.0-20231103055242-5d2c4974156f + require ( github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548 github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 diff --git a/go.sum b/go.sum index 924b5284b..c5eec3075 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/JmPotato/pd/client v0.0.0-20231103055242-5d2c4974156f h1:qaGcHR7GRQHA5MAAZDbqkF7f9Dmp0YbPsbGoYee2Vzw= +github.com/JmPotato/pd/client v0.0.0-20231103055242-5d2c4974156f/go.mod h1:cd6zBqRM9aogxf26K8NnFRPVtq9BnRE59tKEpX8IaWQ= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= @@ -111,8 +114,6 @@ github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a h1:J/YdBZ46WKpXsxsW93SG+q0F8KI+yFrcIDT4c/RNoc4= github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a/go.mod h1:h4xBhSNtOeEosLJ4P7JyKXX7Cabg7AVkWCK5gV2vOrM= -github.com/tikv/pd/client v0.0.0-20230724080549-de985b8e0afc h1:IUg0j2nWoGYj3FQ3vA3vg97fPSpJEZQrDpgF8RkMLEU= -github.com/tikv/pd/client v0.0.0-20230724080549-de985b8e0afc/go.mod h1:wfHRc4iYaqJiOQZCHcrF+r4hYnkGDaYWDfcicee//pc= github.com/twmb/murmur3 v1.1.3 h1:D83U0XYKcHRYwYIpBKf3Pks91Z0Byda/9SJ8B6EMRcA= github.com/twmb/murmur3 v1.1.3/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/tikv/kv.go b/tikv/kv.go index 0d909c29f..dbbe512f5 100644 --- a/tikv/kv.go +++ b/tikv/kv.go @@ -66,6 +66,7 @@ import ( "github.com/tikv/client-go/v2/txnkv/txnsnapshot" "github.com/tikv/client-go/v2/util" pd "github.com/tikv/pd/client" + pdhttp "github.com/tikv/pd/client/http" resourceControlClient "github.com/tikv/pd/client/resource_group/controller" clientv3 "go.etcd.io/etcd/client/v3" atomicutil "go.uber.org/atomic" @@ -115,7 +116,7 @@ type KVStore struct { client Client } pdClient pd.Client - pdHttpClient *util.PDHTTPClient + pdHttpClient pdhttp.HTTPClient regionCache *locate.RegionCache lockResolver *txnlock.LockResolver txnLatches *latch.LatchesScheduler @@ -197,7 +198,7 @@ func WithPool(gp Pool) Option { // WithPDHTTPClient set the PD HTTP client with the given address and TLS config. func WithPDHTTPClient(tlsConf *tls.Config, pdaddrs []string) Option { return func(o *KVStore) { - o.pdHttpClient = util.NewPDHTTPClient(tlsConf, pdaddrs) + o.pdHttpClient = pdhttp.NewHTTPClient(pdaddrs, pdhttp.WithTLSConfig(tlsConf)) } } @@ -444,6 +445,11 @@ func (s *KVStore) GetPDClient() pd.Client { return s.pdClient } +// GetPDHTTPClient returns the PD HTTP client. +func (s *KVStore) GetPDHTTPClient() pdhttp.HTTPClient { + return s.pdHttpClient +} + // SupportDeleteRange gets the storage support delete range or not. func (s *KVStore) SupportDeleteRange() (supported bool) { return !s.mock