Skip to content

Commit

Permalink
*: move some common libraries to the client/pkg directory (#8858)
Browse files Browse the repository at this point in the history
ref #8690

Move some common libraries to the `client/pkg` directory.

Signed-off-by: JmPotato <[email protected]>
  • Loading branch information
JmPotato authored Nov 26, 2024
1 parent f91605a commit da0000a
Show file tree
Hide file tree
Showing 49 changed files with 52 additions and 52 deletions.
4 changes: 2 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ import (
"github.com/pingcap/kvproto/pkg/pdpb"
"github.com/pingcap/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/tikv/pd/client/caller"
"github.com/tikv/pd/client/clients/metastorage"
"github.com/tikv/pd/client/clients/tso"
"github.com/tikv/pd/client/constants"
"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/metrics"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/pkg/caller"
"github.com/tikv/pd/client/pkg/utils/tlsutil"
sd "github.com/tikv/pd/client/servicediscovery"
"github.com/tikv/pd/client/utils/tlsutil"
"go.uber.org/zap"
)

Expand Down
6 changes: 3 additions & 3 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
"time"

"github.com/stretchr/testify/require"
"github.com/tikv/pd/client/caller"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/utils/testutil"
"github.com/tikv/pd/client/utils/tsoutil"
"github.com/tikv/pd/client/pkg/caller"
"github.com/tikv/pd/client/pkg/utils/testutil"
"github.com/tikv/pd/client/pkg/utils/tsoutil"
"go.uber.org/goleak"
)

Expand Down
4 changes: 2 additions & 2 deletions client/clients/tso/tso_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import (
"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/metrics"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/pkg/utils/grpcutil"
"github.com/tikv/pd/client/pkg/utils/tlsutil"
sd "github.com/tikv/pd/client/servicediscovery"
"github.com/tikv/pd/client/utils/grpcutil"
"github.com/tikv/pd/client/utils/tlsutil"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
Expand Down
8 changes: 4 additions & 4 deletions client/clients/tso/tso_dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ import (
"github.com/pingcap/errors"
"github.com/pingcap/failpoint"
"github.com/pingcap/log"
"github.com/tikv/pd/client/batch"
"github.com/tikv/pd/client/constants"
"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/metrics"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/retry"
"github.com/tikv/pd/client/pkg/batch"
"github.com/tikv/pd/client/pkg/retry"
"github.com/tikv/pd/client/pkg/utils/timerutil"
"github.com/tikv/pd/client/pkg/utils/tsoutil"
sd "github.com/tikv/pd/client/servicediscovery"
"github.com/tikv/pd/client/utils/timerutil"
"github.com/tikv/pd/client/utils/tsoutil"
"go.uber.org/zap"
)

Expand Down
2 changes: 1 addition & 1 deletion client/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/pingcap/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/retry"
"github.com/tikv/pd/client/pkg/retry"
sd "github.com/tikv/pd/client/servicediscovery"
"go.uber.org/zap"
)
Expand Down
2 changes: 1 addition & 1 deletion client/http/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/stretchr/testify/require"
"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/retry"
"github.com/tikv/pd/client/pkg/retry"
)

func TestPDAllowFollowerHandleHeader(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion client/http/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/pingcap/kvproto/pkg/keyspacepb"
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/kvproto/pkg/pdpb"
"github.com/tikv/pd/client/retry"
"github.com/tikv/pd/client/pkg/retry"
)

// Client is a PD (Placement Driver) HTTP client.
Expand Down
2 changes: 1 addition & 1 deletion client/http/request_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package http
import (
"fmt"

"github.com/tikv/pd/client/retry"
"github.com/tikv/pd/client/pkg/retry"
"go.uber.org/zap"
)

Expand Down
2 changes: 1 addition & 1 deletion client/meta_storage_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/metrics"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/utils/grpcutil"
"github.com/tikv/pd/client/pkg/utils/grpcutil"
)

// metaStorageClient gets the meta storage client from current PD leader.
Expand Down
2 changes: 1 addition & 1 deletion client/opt/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"time"

"github.com/stretchr/testify/require"
"github.com/tikv/pd/client/utils/testutil"
"github.com/tikv/pd/client/pkg/utils/testutil"
)

func TestDynamicOptionChange(t *testing.T) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
func TestGetComponent(t *testing.T) {
re := require.New(t)

re.Equal(Component("github.com/tikv/pd/client/caller"), GetComponent(0))
re.Equal(Component("github.com/tikv/pd/client/pkg/caller"), GetComponent(0))
re.Equal(Component("testing"), GetComponent(1))
re.Equal(Component("runtime"), GetComponent(2))
re.Equal(Component("unknown"), GetComponent(3))
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions client/servicediscovery/pd_service_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import (
"github.com/tikv/pd/client/constants"
"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/retry"
"github.com/tikv/pd/client/utils/grpcutil"
"github.com/tikv/pd/client/utils/tlsutil"
"github.com/tikv/pd/client/pkg/retry"
"github.com/tikv/pd/client/pkg/utils/grpcutil"
"github.com/tikv/pd/client/pkg/utils/tlsutil"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
Expand Down
6 changes: 3 additions & 3 deletions client/servicediscovery/pd_service_discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (
"github.com/stretchr/testify/suite"
"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/utils/grpcutil"
"github.com/tikv/pd/client/utils/testutil"
"github.com/tikv/pd/client/utils/tlsutil"
"github.com/tikv/pd/client/pkg/utils/grpcutil"
"github.com/tikv/pd/client/pkg/utils/testutil"
"github.com/tikv/pd/client/pkg/utils/tlsutil"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
pb "google.golang.org/grpc/examples/helloworld/helloworld"
Expand Down
2 changes: 1 addition & 1 deletion client/servicediscovery/tso_service_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"github.com/tikv/pd/client/constants"
"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/utils/grpcutil"
"github.com/tikv/pd/client/pkg/utils/grpcutil"
"go.uber.org/zap"
"google.golang.org/grpc"
)
Expand Down
16 changes: 8 additions & 8 deletions tests/integrations/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
pd "github.com/tikv/pd/client"
"github.com/tikv/pd/client/caller"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/retry"
"github.com/tikv/pd/client/pkg/caller"
"github.com/tikv/pd/client/pkg/retry"
sd "github.com/tikv/pd/client/servicediscovery"
"github.com/tikv/pd/pkg/core"
"github.com/tikv/pd/pkg/mcs/utils/constant"
Expand Down Expand Up @@ -586,7 +586,7 @@ func (suite *followerForwardAndHandleTestSuite) TestGetTsoAndRegionByFollowerFor
leader := cluster.GetLeaderServer()

follower := cluster.GetServer(cluster.GetFollower())
re.NoError(failpoint.Enable("github.com/tikv/pd/client/utils/grpcutil/unreachableNetwork2", fmt.Sprintf("return(\"%s\")", follower.GetAddr())))
re.NoError(failpoint.Enable("github.com/tikv/pd/client/pkg/utils/grpcutil/unreachableNetwork2", fmt.Sprintf("return(\"%s\")", follower.GetAddr())))

cli := setupCli(ctx, re, suite.endpoints, opt.WithForwardingOption(true))
defer cli.Close()
Expand Down Expand Up @@ -625,7 +625,7 @@ func (suite *followerForwardAndHandleTestSuite) TestGetTsoAndRegionByFollowerFor
return false
})

re.NoError(failpoint.Disable("github.com/tikv/pd/client/utils/grpcutil/unreachableNetwork2"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/pkg/utils/grpcutil/unreachableNetwork2"))
testutil.Eventually(re, func() bool {
physical, logical, err := cli.GetTS(context.TODO())
if err == nil {
Expand Down Expand Up @@ -655,7 +655,7 @@ func (suite *followerForwardAndHandleTestSuite) TestGetRegionFromLeaderWhenNetwo
leader := cluster.GetLeaderServer()

follower := cluster.GetServer(cluster.GetFollower())
re.NoError(failpoint.Enable("github.com/tikv/pd/client/utils/grpcutil/unreachableNetwork2", fmt.Sprintf("return(\"%s\")", follower.GetAddr())))
re.NoError(failpoint.Enable("github.com/tikv/pd/client/pkg/utils/grpcutil/unreachableNetwork2", fmt.Sprintf("return(\"%s\")", follower.GetAddr())))

cli := setupCli(ctx, re, suite.endpoints)
defer cli.Close()
Expand All @@ -673,7 +673,7 @@ func (suite *followerForwardAndHandleTestSuite) TestGetRegionFromLeaderWhenNetwo
re.Error(err)
re.Nil(r)

re.NoError(failpoint.Disable("github.com/tikv/pd/client/utils/grpcutil/unreachableNetwork2"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/pkg/utils/grpcutil/unreachableNetwork2"))
cli.GetServiceDiscovery().CheckMemberChanged()
testutil.Eventually(re, func() bool {
r, err = cli.GetRegion(context.Background(), []byte("a"))
Expand Down Expand Up @@ -1790,7 +1790,7 @@ func (suite *clientTestSuite) TestMemberUpdateBackOff() {
re.NoError(failpoint.Enable("github.com/tikv/pd/server/exitCampaignLeader", fmt.Sprintf("return(\"%d\")", memberID)))
re.NoError(failpoint.Enable("github.com/tikv/pd/server/timeoutWaitPDLeader", `return(true)`))
// make sure back off executed.
re.NoError(failpoint.Enable("github.com/tikv/pd/client/retry/backOffExecute", `return(true)`))
re.NoError(failpoint.Enable("github.com/tikv/pd/client/pkg/retry/backOffExecute", `return(true)`))
leader2 := waitLeaderChange(re, cluster, leader, innerCli.GetServiceDiscovery())
re.True(retry.TestBackOffExecute())

Expand All @@ -1799,7 +1799,7 @@ func (suite *clientTestSuite) TestMemberUpdateBackOff() {
re.NoError(failpoint.Disable("github.com/tikv/pd/server/leaderLoopCheckAgain"))
re.NoError(failpoint.Disable("github.com/tikv/pd/server/exitCampaignLeader"))
re.NoError(failpoint.Disable("github.com/tikv/pd/server/timeoutWaitPDLeader"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/retry/backOffExecute"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/pkg/retry/backOffExecute"))
}

func waitLeaderChange(re *require.Assertions, cluster *tests.TestCluster, old string, cli sd.ServiceDiscovery) string {
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/client/client_tls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (

"github.com/stretchr/testify/require"
pd "github.com/tikv/pd/client"
"github.com/tikv/pd/client/caller"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/pkg/caller"
"github.com/tikv/pd/pkg/utils/grpcutil"
"github.com/tikv/pd/pkg/utils/netutil"
"github.com/tikv/pd/server/config"
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/client/gc_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
pd "github.com/tikv/pd/client"
"github.com/tikv/pd/client/caller"
"github.com/tikv/pd/client/pkg/caller"
"github.com/tikv/pd/pkg/utils/assertutil"
"github.com/tikv/pd/pkg/utils/keypath"
"github.com/tikv/pd/pkg/utils/testutil"
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/client/global_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"time"

pd "github.com/tikv/pd/client"
"github.com/tikv/pd/client/caller"
"github.com/tikv/pd/client/pkg/caller"

"github.com/pingcap/kvproto/pkg/pdpb"
"github.com/pingcap/log"
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/client/http_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
pd "github.com/tikv/pd/client/http"
"github.com/tikv/pd/client/retry"
"github.com/tikv/pd/client/pkg/retry"
"github.com/tikv/pd/pkg/core"
"github.com/tikv/pd/pkg/keyspace"
sc "github.com/tikv/pd/pkg/schedule/config"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
pd "github.com/tikv/pd/client"
"github.com/tikv/pd/client/caller"
"github.com/tikv/pd/client/pkg/caller"
"github.com/tikv/pd/client/resource_group/controller"
sd "github.com/tikv/pd/client/servicediscovery"
"github.com/tikv/pd/pkg/mcs/resourcemanager/server"
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/mcs/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (

"github.com/stretchr/testify/require"
pd "github.com/tikv/pd/client"
"github.com/tikv/pd/client/caller"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/pkg/caller"
"github.com/tikv/pd/pkg/utils/testutil"
"github.com/tikv/pd/pkg/utils/tsoutil"
)
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/mcs/tso/keyspace_group_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
pd "github.com/tikv/pd/client"
"github.com/tikv/pd/client/caller"
clierrs "github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/pkg/caller"
"github.com/tikv/pd/pkg/election"
"github.com/tikv/pd/pkg/errs"
"github.com/tikv/pd/pkg/mcs/utils/constant"
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/mcs/tso/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/pingcap/log"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/tikv/pd/client/utils/tsoutil"
"github.com/tikv/pd/client/pkg/utils/tsoutil"
"github.com/tikv/pd/pkg/utils/testutil"
"github.com/tikv/pd/tests"
"go.uber.org/zap"
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/mcs/tso/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
pd "github.com/tikv/pd/client"
"github.com/tikv/pd/client/caller"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/pkg/caller"
"github.com/tikv/pd/pkg/core"
"github.com/tikv/pd/pkg/mcs/discovery"
tso "github.com/tikv/pd/pkg/mcs/tso/server"
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/realcluster/cluster_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
pd "github.com/tikv/pd/client"
"github.com/tikv/pd/client/caller"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/pkg/caller"
)

type clusterIDSuite struct {
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/realcluster/etcd_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/tikv/pd/client/utils/testutil"
"github.com/tikv/pd/client/pkg/utils/testutil"
)

type etcdKeySuite struct {
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/realcluster/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/tikv/pd/client/http"
"github.com/tikv/pd/client/utils/testutil"
"github.com/tikv/pd/client/pkg/utils/testutil"
"github.com/tikv/pd/pkg/schedule/labeler"
"github.com/tikv/pd/pkg/schedule/types"
"go.uber.org/zap"
Expand Down
4 changes: 2 additions & 2 deletions tests/integrations/tso/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
pd "github.com/tikv/pd/client"
"github.com/tikv/pd/client/caller"
"github.com/tikv/pd/client/clients/tso"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/pkg/caller"
"github.com/tikv/pd/client/pkg/utils/testutil"
sd "github.com/tikv/pd/client/servicediscovery"
"github.com/tikv/pd/client/utils/testutil"
bs "github.com/tikv/pd/pkg/basicserver"
"github.com/tikv/pd/pkg/mcs/utils/constant"
"github.com/tikv/pd/pkg/slice"
Expand Down
4 changes: 2 additions & 2 deletions tools/pd-api-bench/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ import (
"github.com/prometheus/client_golang/prometheus"
flag "github.com/spf13/pflag"
pd "github.com/tikv/pd/client"
"github.com/tikv/pd/client/caller"
pdHttp "github.com/tikv/pd/client/http"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/utils/tlsutil"
"github.com/tikv/pd/client/pkg/caller"
"github.com/tikv/pd/client/pkg/utils/tlsutil"
"github.com/tikv/pd/pkg/mcs/utils"
"github.com/tikv/pd/pkg/utils/logutil"
"github.com/tikv/pd/tools/pd-api-bench/cases"
Expand Down
4 changes: 2 additions & 2 deletions tools/pd-heartbeat-bench/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ import (
"github.com/pingcap/log"
"github.com/spf13/pflag"
pdHttp "github.com/tikv/pd/client/http"
"github.com/tikv/pd/client/utils/grpcutil"
"github.com/tikv/pd/client/utils/tlsutil"
"github.com/tikv/pd/client/pkg/utils/grpcutil"
"github.com/tikv/pd/client/pkg/utils/tlsutil"
"github.com/tikv/pd/pkg/codec"
"github.com/tikv/pd/pkg/mcs/utils"
"github.com/tikv/pd/pkg/statistics"
Expand Down
2 changes: 1 addition & 1 deletion tools/pd-tso-bench/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import (
"github.com/pingcap/log"
"github.com/prometheus/client_golang/prometheus/promhttp"
pd "github.com/tikv/pd/client"
"github.com/tikv/pd/client/caller"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/pkg/caller"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/keepalive"
Expand Down

0 comments on commit da0000a

Please sign in to comment.