Repository: tikv/client-go
Pull request #194 (2021-06-30 04:19:06)

move client to internal package
Signed-off-by: disksing <i@disksing.com>

Fix https://github.com/tikv/client-go/issues/193


Patch:
diff --git a/client/client.go b/internal/client/client.go
similarity index 100%
rename from client/client.go
rename to internal/client/client.go
diff --git a/client/client_batch.go b/internal/client/client_batch.go
similarity index 100%
rename from client/client_batch.go
rename to internal/client/client_batch.go
diff --git a/client/client_collapse.go b/internal/client/client_collapse.go
similarity index 100%
rename from client/client_collapse.go
rename to internal/client/client_collapse.go
diff --git a/client/client_fail_test.go b/internal/client/client_fail_test.go
similarity index 100%
rename from client/client_fail_test.go
rename to internal/client/client_fail_test.go
diff --git a/client/client_test.go b/internal/client/client_test.go
similarity index 100%
rename from client/client_test.go
rename to internal/client/client_test.go
diff --git a/client/main_test.go b/internal/client/main_test.go
similarity index 100%
rename from client/main_test.go
rename to internal/client/main_test.go
diff --git a/client/mock_tikv_service_test.go b/internal/client/mock_tikv_service_test.go
similarity index 100%
rename from client/mock_tikv_service_test.go
rename to internal/client/mock_tikv_service_test.go
diff --git a/internal/locate/region_cache.go b/internal/locate/region_cache.go
index f5fb472..181faa8 100644
--- a/internal/locate/region_cache.go
+++ b/internal/locate/region_cache.go
@@ -49,8 +49,8 @@ import (
 	"github.com/pingcap/errors"
 	"github.com/pingcap/kvproto/pkg/metapb"
 	"github.com/pingcap/parser/terror"
-	"github.com/tikv/client-go/v2/client"
 	"github.com/tikv/client-go/v2/config"
+	"github.com/tikv/client-go/v2/internal/client"
 	"github.com/tikv/client-go/v2/internal/retry"
 	"github.com/tikv/client-go/v2/kv"
 	"github.com/tikv/client-go/v2/logutil"
diff --git a/internal/locate/region_request.go b/internal/locate/region_request.go
index fd7ea83..2849bc2 100644
--- a/internal/locate/region_request.go
+++ b/internal/locate/region_request.go
@@ -51,8 +51,8 @@ import (
 	"github.com/pingcap/kvproto/pkg/errorpb"
 	"github.com/pingcap/kvproto/pkg/kvrpcpb"
 	"github.com/pingcap/kvproto/pkg/metapb"
-	"github.com/tikv/client-go/v2/client"
 	tikverr "github.com/tikv/client-go/v2/error"
+	"github.com/tikv/client-go/v2/internal/client"
 	"github.com/tikv/client-go/v2/internal/retry"
 	"github.com/tikv/client-go/v2/kv"
 	"github.com/tikv/client-go/v2/logutil"
diff --git a/tikv/2pc.go b/tikv/2pc.go
index fe86222..3fe9048 100644
--- a/tikv/2pc.go
+++ b/tikv/2pc.go
@@ -48,9 +48,9 @@ import (
 	"github.com/pingcap/kvproto/pkg/kvrpcpb"
 	"github.com/pingcap/parser/terror"
 	"github.com/prometheus/client_golang/prometheus"
-	"github.com/tikv/client-go/v2/client"
 	"github.com/tikv/client-go/v2/config"
 	tikverr "github.com/tikv/client-go/v2/error"
+	"github.com/tikv/client-go/v2/internal/client"
 	"github.com/tikv/client-go/v2/internal/locate"
 	"github.com/tikv/client-go/v2/internal/retry"
 	"github.com/tikv/client-go/v2/internal/unionstore"
diff --git a/tikv/cleanup.go b/tikv/cleanup.go
index db15492..c02e745 100644
--- a/tikv/cleanup.go
+++ b/tikv/cleanup.go
@@ -36,7 +36,7 @@ import (
 	"github.com/pingcap/errors"
 	"github.com/pingcap/kvproto/pkg/kvrpcpb"
 	"github.com/prometheus/client_golang/prometheus"
-	"github.com/tikv/client-go/v2/client"
+	"github.com/tikv/client-go/v2/internal/client"
 	"github.com/tikv/client-go/v2/internal/retry"
 	"github.com/tikv/client-go/v2/logutil"
 	"github.com/tikv/client-go/v2/metrics"
diff --git a/tikv/client.go b/tikv/client.go
index 8fb903d..1f31ce0 100644
--- a/tikv/client.go
+++ b/tikv/client.go
@@ -33,8 +33,8 @@
 package tikv
 
 import (
-	"github.com/tikv/client-go/v2/client"
 	"github.com/tikv/client-go/v2/config"
+	"github.com/tikv/client-go/v2/internal/client"
 )
 
 // Client is a client that sends RPC.
diff --git a/tikv/commit.go b/tikv/commit.go
index 033b041..75a13ed 100644
--- a/tikv/commit.go
+++ b/tikv/commit.go
@@ -40,8 +40,8 @@ import (
 	"github.com/pingcap/errors"
 	"github.com/pingcap/kvproto/pkg/kvrpcpb"
 	"github.com/prometheus/client_golang/prometheus"
-	"github.com/tikv/client-go/v2/client"
 	tikverr "github.com/tikv/client-go/v2/error"
+	"github.com/tikv/client-go/v2/internal/client"
 	"github.com/tikv/client-go/v2/internal/locate"
 	"github.com/tikv/client-go/v2/internal/retry"
 	"github.com/tikv/client-go/v2/logutil"
diff --git a/tikv/delete_range.go b/tikv/delete_range.go
index ee1bb87..037197a 100644
--- a/tikv/delete_range.go
+++ b/tikv/delete_range.go
@@ -38,8 +38,8 @@ import (
 
 	"github.com/pingcap/errors"
 	"github.com/pingcap/kvproto/pkg/kvrpcpb"
-	"github.com/tikv/client-go/v2/client"
 	tikverr "github.com/tikv/client-go/v2/error"
+	"github.com/tikv/client-go/v2/internal/client"
 	"github.com/tikv/client-go/v2/internal/retry"
 	"github.com/tikv/client-go/v2/kv"
 	"github.com/tikv/client-go/v2/tikvrpc"
diff --git a/tikv/kv.go b/tikv/kv.go
index a7a128b..86c3d5f 100644
--- a/tikv/kv.go
+++ b/tikv/kv.go
@@ -47,9 +47,9 @@ import (
 	"github.com/pingcap/errors"
 	"github.com/pingcap/kvproto/pkg/kvrpcpb"
 	"github.com/pingcap/kvproto/pkg/metapb"
-	"github.com/tikv/client-go/v2/client"
 	"github.com/tikv/client-go/v2/config"
 	tikverr "github.com/tikv/client-go/v2/error"
+	"github.com/tikv/client-go/v2/internal/client"
 	"github.com/tikv/client-go/v2/internal/latch"
 	"github.com/tikv/client-go/v2/internal/locate"
 	"github.com/tikv/client-go/v2/internal/retry"
diff --git a/tikv/lock_resolver.go b/tikv/lock_resolver.go
index 3810cf4..9b1eaff 100644
--- a/tikv/lock_resolver.go
+++ b/tikv/lock_resolver.go
@@ -44,9 +44,9 @@ import (
 
 	"github.com/pingcap/errors"
 	"github.com/pingcap/kvproto/pkg/kvrpcpb"
-	"github.com/tikv/client-go/v2/client"
 	"github.com/tikv/client-go/v2/config"
 	tikverr "github.com/tikv/client-go/v2/error"
+	"github.com/tikv/client-go/v2/internal/client"
 	"github.com/tikv/client-go/v2/internal/locate"
 	"github.com/tikv/client-go/v2/internal/retry"
 	"github.com/tikv/client-go/v2/logutil"
diff --git a/tikv/pessimistic.go b/tikv/pessimistic.go
index 2fa0cf9..26d6d59 100644
--- a/tikv/pessimistic.go
+++ b/tikv/pessimistic.go
@@ -42,8 +42,8 @@ import (
 	"github.com/pingcap/errors"
 	"github.com/pingcap/kvproto/pkg/kvrpcpb"
 	"github.com/prometheus/client_golang/prometheus"
-	"github.com/tikv/client-go/v2/client"
 	tikverr "github.com/tikv/client-go/v2/error"
+	"github.com/tikv/client-go/v2/internal/client"
 	"github.com/tikv/client-go/v2/internal/locate"
 	"github.com/tikv/client-go/v2/internal/retry"
 	"github.com/tikv/client-go/v2/kv"
diff --git a/tikv/prewrite.go b/tikv/prewrite.go
index 2d4f649..a12cd0f 100644
--- a/tikv/prewrite.go
+++ b/tikv/prewrite.go
@@ -42,9 +42,9 @@ import (
 	"github.com/pingcap/errors"
 	"github.com/pingcap/kvproto/pkg/kvrpcpb"
 	"github.com/prometheus/client_golang/prometheus"
-	"github.com/tikv/client-go/v2/client"
 	"github.com/tikv/client-go/v2/config"
 	tikverr "github.com/tikv/client-go/v2/error"
+	"github.com/tikv/client-go/v2/internal/client"
 	"github.com/tikv/client-go/v2/internal/locate"
 	"github.com/tikv/client-go/v2/internal/retry"
 	"github.com/tikv/client-go/v2/logutil"
diff --git a/tikv/rawkv.go b/tikv/rawkv.go
index 70fbfe2..8c22eb8 100644
--- a/tikv/rawkv.go
+++ b/tikv/rawkv.go
@@ -39,9 +39,9 @@ import (
 
 	"github.com/pingcap/errors"
 	"github.com/pingcap/kvproto/pkg/kvrpcpb"
-	"github.com/tikv/client-go/v2/client"
 	"github.com/tikv/client-go/v2/config"
 	tikverr "github.com/tikv/client-go/v2/error"
+	"github.com/tikv/client-go/v2/internal/client"
 	"github.com/tikv/client-go/v2/internal/locate"
 	"github.com/tikv/client-go/v2/internal/retry"
 	"github.com/tikv/client-go/v2/metrics"
diff --git a/tikv/region.go b/tikv/region.go
index 8d48c71..c785d13 100644
--- a/tikv/region.go
+++ b/tikv/region.go
@@ -36,7 +36,7 @@ import (
 	"time"
 
 	"github.com/pingcap/kvproto/pkg/metapb"
-	"github.com/tikv/client-go/v2/client"
+	"github.com/tikv/client-go/v2/internal/client"
 	"github.com/tikv/client-go/v2/internal/locate"
 	"github.com/tikv/client-go/v2/tikvrpc"
 	pd "github.com/tikv/pd/client"
diff --git a/tikv/scan.go b/tikv/scan.go
index 9da4ee0..2a1fa2c 100644
--- a/tikv/scan.go
+++ b/tikv/scan.go
@@ -38,8 +38,8 @@ import (
 
 	"github.com/pingcap/errors"
 	"github.com/pingcap/kvproto/pkg/kvrpcpb"
-	"github.com/tikv/client-go/v2/client"
 	tikverr "github.com/tikv/client-go/v2/error"
+	"github.com/tikv/client-go/v2/internal/client"
 	"github.com/tikv/client-go/v2/internal/locate"
 	"github.com/tikv/client-go/v2/internal/retry"
 	"github.com/tikv/client-go/v2/kv"
diff --git a/tikv/snapshot.go b/tikv/snapshot.go
index cf53f27..fb6b2d6 100644
--- a/tikv/snapshot.go
+++ b/tikv/snapshot.go
@@ -46,8 +46,8 @@ import (
 	"github.com/pingcap/failpoint"
 	"github.com/pingcap/kvproto/pkg/kvrpcpb"
 	"github.com/pingcap/kvproto/pkg/metapb"
-	"github.com/tikv/client-go/v2/client"
 	tikverr "github.com/tikv/client-go/v2/error"
+	"github.com/tikv/client-go/v2/internal/client"
 	"github.com/tikv/client-go/v2/internal/locate"
 	"github.com/tikv/client-go/v2/internal/retry"
 	"github.com/tikv/client-go/v2/kv"
diff --git a/tikv/split_region.go b/tikv/split_region.go
index 830f853..a635251 100644
--- a/tikv/split_region.go
+++ b/tikv/split_region.go
@@ -43,8 +43,8 @@ import (
 	"github.com/pingcap/kvproto/pkg/kvrpcpb"
 	"github.com/pingcap/kvproto/pkg/metapb"
 	"github.com/pingcap/kvproto/pkg/pdpb"
-	"github.com/tikv/client-go/v2/client"
 	tikverr "github.com/tikv/client-go/v2/error"
+	"github.com/tikv/client-go/v2/internal/client"
 	"github.com/tikv/client-go/v2/internal/locate"
 	"github.com/tikv/client-go/v2/internal/retry"
 	"github.com/tikv/client-go/v2/kv"


Test patch:
diff --git a/integration_tests/client_fp_test.go b/integration_tests/client_fp_test.go
index fc69300..d39f01d 100644
--- a/integration_tests/client_fp_test.go
+++ b/integration_tests/client_fp_test.go
@@ -20,14 +20,14 @@ import (
 	"github.com/pingcap/errors"
 	"github.com/pingcap/kvproto/pkg/kvrpcpb"
 	"github.com/pingcap/parser/terror"
-	"github.com/tikv/client-go/v2/client"
+	"github.com/tikv/client-go/v2/tikv"
 	"github.com/tikv/client-go/v2/tikvrpc"
 	"github.com/tikv/client-go/v2/util"
 )
 
 // mock TiKV RPC client that hooks message by failpoint
 type fpClient struct {
-	client.Client
+	tikv.Client
 }
 
 func (c fpClient) SendRequest(ctx context.Context, addr string, req *tikvrpc.Request, timeout time.Duration) (*tikvrpc.Response, error) {
diff --git a/internal/locate/region_request_test.go b/internal/locate/region_request_test.go
index 0bb6e60..cdbd264 100644
--- a/internal/locate/region_request_test.go
+++ b/internal/locate/region_request_test.go
@@ -49,8 +49,8 @@ import (
 	"github.com/pingcap/kvproto/pkg/mpp"
 	"github.com/pingcap/kvproto/pkg/tikvpb"
 	"github.com/stretchr/testify/suite"
-	"github.com/tikv/client-go/v2/client"
 	"github.com/tikv/client-go/v2/config"
+	"github.com/tikv/client-go/v2/internal/client"
 	"github.com/tikv/client-go/v2/internal/retry"
 	"github.com/tikv/client-go/v2/mockstore/mocktikv"
 	"github.com/tikv/client-go/v2/tikvrpc"