From edc498f339dc9253382c7101863e7c33a2b0cb53 Mon Sep 17 00:00:00 2001 From: husharp Date: Wed, 3 Jan 2024 14:15:02 +0800 Subject: [PATCH] rename api Signed-off-by: husharp --- client/http/api.go | 4 ++-- client/http/interface.go | 10 +++++----- client/http/types.go | 4 ++-- tools/pd-ctl/pdctl/command/cluster_command.go | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/client/http/api.go b/client/http/api.go index 9bf5addb2e6..bd0bf830a1f 100644 --- a/client/http/api.go +++ b/client/http/api.go @@ -73,8 +73,8 @@ const ( PProfGoroutine = "/pd/api/v1/debug/pprof/goroutine" // Others MinResolvedTSPrefix = "/pd/api/v1/min-resolved-ts" - ClusterPrefix = "/pd/api/v1/cluster" - ClusterStatusPrefix = "/pd/api/v1/cluster/status" + Cluster = "/pd/api/v1/cluster" + ClusterStatus = "/pd/api/v1/cluster/status" Status = "/pd/api/v1/status" Version = "/pd/api/v1/version" // Micro Service diff --git a/client/http/interface.go b/client/http/interface.go index 2def95f0afe..0b59d69b548 100644 --- a/client/http/interface.go +++ b/client/http/interface.go @@ -51,7 +51,7 @@ type Client interface { SetScheduleConfig(context.Context, map[string]interface{}) error GetClusterVersion(context.Context) (string, error) GetCluster(context.Context) (*metapb.Cluster, error) - GetClusterStatus(context.Context) (*ClusterStatus, error) + GetClusterStatus(context.Context) (*ClusterState, error) GetReplicateConfig(context.Context) (map[string]interface{}, error) /* Scheduler-related interfaces */ GetSchedulers(context.Context) ([]string, error) @@ -369,7 +369,7 @@ func (c *client) GetCluster(ctx context.Context) (*metapb.Cluster, error) { var clusterInfo *metapb.Cluster err := c.request(ctx, newRequestInfo(). WithName(getClusterName). - WithURI(ClusterPrefix). + WithURI(Cluster). WithMethod(http.MethodGet). WithResp(&clusterInfo)) if err != nil { @@ -379,11 +379,11 @@ func (c *client) GetCluster(ctx context.Context) (*metapb.Cluster, error) { } // GetClusterStatus gets the cluster status. -func (c *client) GetClusterStatus(ctx context.Context) (*ClusterStatus, error) { - var clusterStatus *ClusterStatus +func (c *client) GetClusterStatus(ctx context.Context) (*ClusterState, error) { + var clusterStatus *ClusterState err := c.request(ctx, newRequestInfo(). WithName(getClusterName). - WithURI(ClusterStatusPrefix). + WithURI(ClusterStatus). WithMethod(http.MethodGet). WithResp(&clusterStatus)) if err != nil { diff --git a/client/http/types.go b/client/http/types.go index ce0a917632a..59f9077262b 100644 --- a/client/http/types.go +++ b/client/http/types.go @@ -24,9 +24,9 @@ import ( "github.com/pingcap/kvproto/pkg/pdpb" ) -// ClusterStatus saves some cluster state information. +// ClusterState saves some cluster state information. // NOTE: This type sync with https://github.com/tikv/pd/blob/5eae459c01a797cbd0c416054c6f0cad16b8740a/server/cluster/cluster.go#L173 -type ClusterStatus struct { +type ClusterState struct { RaftBootstrapTime time.Time `json:"raft_bootstrap_time,omitempty"` IsInitialized bool `json:"is_initialized"` ReplicationStatus string `json:"replication_status"` diff --git a/tools/pd-ctl/pdctl/command/cluster_command.go b/tools/pd-ctl/pdctl/command/cluster_command.go index 722fc3f14a3..4fd7b8be61a 100644 --- a/tools/pd-ctl/pdctl/command/cluster_command.go +++ b/tools/pd-ctl/pdctl/command/cluster_command.go @@ -41,7 +41,7 @@ func NewClusterStatusCommand() *cobra.Command { return r } -func showClusterCommandFunc(cmd *cobra.Command, args []string) { +func showClusterCommandFunc(cmd *cobra.Command, _ []string) { info, err := PDCli.GetCluster(context.Background()) if err != nil { cmd.Printf("Failed to get the cluster information: %s\n", err) @@ -50,7 +50,7 @@ func showClusterCommandFunc(cmd *cobra.Command, args []string) { jsonPrint(cmd, info) } -func showClusterStatusCommandFunc(cmd *cobra.Command, args []string) { +func showClusterStatusCommandFunc(cmd *cobra.Command, _ []string) { status, err := PDCli.GetClusterStatus(context.Background()) if err != nil { cmd.Printf("Failed to get the cluster status: %s\n", err)