Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FindAllShardsInKeyspace to vtctldserver #7201

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 43 additions & 0 deletions go/cmd/vtctldclient/commands.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
/*
Copyright 2020 The Vitess Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"encoding/json"
"fmt"

"github.com/spf13/cobra"
Expand All @@ -9,6 +26,12 @@ import (
)

var (
findAllShardsInKeyspaceCmd = &cobra.Command{
Use: "FindAllShardsInKeyspace keyspace",
Aliases: []string{"findallshardsinkeyspace"},
Args: cobra.ExactArgs(1),
RunE: commandFindAllShardsInKeyspace,
}
getKeyspaceCmd = &cobra.Command{
Use: "GetKeyspace keyspace",
Aliases: []string{"getkeyspace"},
Expand All @@ -23,6 +46,25 @@ var (
}
)

func commandFindAllShardsInKeyspace(cmd *cobra.Command, args []string) error {
ks := cmd.Flags().Arg(0)
resp, err := client.FindAllShardsInKeyspace(commandCtx, &vtctldatapb.FindAllShardsInKeyspaceRequest{
Keyspace: ks,
})

if err != nil {
return err
}

data, err := json.Marshal(&resp)
if err != nil {
return err
}

fmt.Printf("%s\n", data)
return nil
}

func commandGetKeyspace(cmd *cobra.Command, args []string) error {
ks := cmd.Flags().Arg(0)
resp, err := client.GetKeyspace(commandCtx, &vtctldatapb.GetKeyspaceRequest{
Expand Down Expand Up @@ -50,6 +92,7 @@ func commandGetKeyspaces(cmd *cobra.Command, args []string) error {
}

func init() {
rootCmd.AddCommand(findAllShardsInKeyspaceCmd)
rootCmd.AddCommand(getKeyspaceCmd)
rootCmd.AddCommand(getKeyspacesCmd)
}
2 changes: 1 addition & 1 deletion go/cmd/vtctldclient/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019 The Vitess Authors.
Copyright 2020 The Vitess Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/vtctldclient/plugin_grpcvtctldclient.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019 The Vitess Authors.
Copyright 2020 The Vitess Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
216 changes: 180 additions & 36 deletions go/vt/proto/vtctldata/vtctldata.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.