Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ endif
install: build
# binaries
mkdir -p "$${PREFIX}/bin"
cp "$${VTROOT}/bin/"{mysqlctld,vtorc,vtctld,vtctlclient,vtgate,vttablet,vtworker,vtbackup} "$${PREFIX}/bin/"
cp "$${VTROOT}/bin/"{mysqlctld,vtorc,vtctld,vtctlclient,vtctldclient,vtgate,vttablet,vtworker,vtbackup} "$${PREFIX}/bin/"

# Install local install the binaries needed to run vitess locally
# Usage: make install-local PREFIX=/path/to/install/root
install-local: build
# binaries
mkdir -p "$${PREFIX}/bin"
cp "$${VTROOT}/bin/"{mysqlctl,mysqlctld,vtorc,vtctl,vtctld,vtctlclient,vtgate,vttablet,vtworker,vtbackup} "$${PREFIX}/bin/"
cp "$${VTROOT}/bin/"{mysqlctl,mysqlctld,vtorc,vtctl,vtctld,vtctlclient,vtctldclient,vtgate,vttablet,vtworker,vtbackup} "$${PREFIX}/bin/"


# install copies the files needed to run test Vitess using vtcombo into the given directory tree.
Expand Down
2 changes: 1 addition & 1 deletion examples/local/scripts/vtctld-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ vtctld \
-cell $cell \
-workflow_manager_init \
-workflow_manager_use_election \
-service_map 'grpc-vtctl' \
-service_map 'grpc-vtctl,grpc-vtctld' \
-backup_storage_implementation file \
-file_backup_storage_root $VTDATAROOT/backups \
-log_dir $VTDATAROOT/tmp \
Expand Down
18 changes: 6 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module vitess.io/vitess
go 1.13

require (
cloud.google.com/go v0.45.1
cloud.google.com/go/storage v1.0.0
github.com/Azure/azure-pipeline-go v0.2.2
github.com/Azure/azure-storage-blob-go v0.10.0
github.com/Azure/go-autorest/autorest v0.10.0 // indirect
Expand All @@ -17,10 +17,8 @@ require (
github.com/cespare/xxhash/v2 v2.1.1
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0 // indirect
github.com/coreos/bbolt v1.3.2 // indirect
github.com/coreos/etcd v3.3.10+incompatible
github.com/coreos/etcd v3.3.13+incompatible
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/corpix/uarand v0.1.1 // indirect
github.com/cyberdelia/go-metrics-graphite v0.0.0-20161219230853-39f87cc3b432
github.com/evanphx/json-patch v4.5.0+incompatible
Expand All @@ -36,7 +34,7 @@ require (
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/google/uuid v1.1.1
github.com/googleapis/gnostic v0.2.0 // indirect
github.com/gorilla/websocket v1.4.0
github.com/gorilla/websocket v1.4.2
github.com/grpc-ecosystem/go-grpc-middleware v1.1.0
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/hashicorp/consul/api v1.5.0
Expand Down Expand Up @@ -81,33 +79,29 @@ require (
github.com/samuel/go-zookeeper v0.0.0-20200724154423-2164a8ac840e
github.com/satori/go.uuid v1.2.0 // indirect
github.com/sjmudd/stopwatch v0.0.0-20170613150411-f380bf8a9be1
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/spf13/cobra v1.1.1
github.com/spyzhov/ajson v0.4.2
github.com/stretchr/testify v1.4.0
github.com/tchap/go-patricia v0.0.0-20160729071656-dd168db6051b
github.com/tebeka/selenium v0.9.9
github.com/tinylib/msgp v1.1.1 // indirect
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
github.com/uber-go/atomic v1.4.0 // indirect
github.com/uber/jaeger-client-go v2.16.0+incompatible
github.com/uber/jaeger-lib v2.0.0+incompatible // indirect
github.com/ugorji/go v1.1.7 // indirect
github.com/z-division/go-zookeeper v0.0.0-20190128072838-6d7457066b9b
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
golang.org/x/lint v0.0.0-20190409202823-959b441ac422
golang.org/x/lint v0.0.0-20190930215403-16217165b5de
golang.org/x/net v0.0.0-20201021035429-f5854403a974
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
golang.org/x/text v0.3.3
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
golang.org/x/tools v0.0.0-20201202200335-bef1c476418a
google.golang.org/api v0.9.0
google.golang.org/genproto v0.0.0-20190926190326-7ee9db18f195 // indirect
google.golang.org/api v0.13.0
google.golang.org/grpc v1.24.0
gopkg.in/DataDog/dd-trace-go.v1 v1.17.0
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect
gopkg.in/gcfg.v1 v1.2.3
gopkg.in/ini.v1 v1.51.0 // indirect
gopkg.in/ldap.v2 v2.5.0
gopkg.in/warnings.v0 v0.1.2 // indirect
gotest.tools v2.2.0+incompatible
Expand Down
74 changes: 68 additions & 6 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion go/cmd/vtctlclient/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
)

// The default values used by these flags cannot be taken from wrangler and
// actionnode modules, as we do't want to depend on them at all.
// actionnode modules, as we don't want to depend on them at all.
var (
actionTimeout = flag.Duration("action_timeout", time.Hour, "timeout for the total command")
server = flag.String("server", "", "server to use for connection")
Expand Down
30 changes: 30 additions & 0 deletions go/cmd/vtctld/plugin_grpcvtctldserver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Copyright 2019 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 (
"vitess.io/vitess/go/vt/servenv"
"vitess.io/vitess/go/vt/vtctl/grpcvtctldserver"
)

func init() {
servenv.OnRun(func() {
if servenv.GRPCCheckServiceMap("vtctld") {
grpcvtctldserver.StartServer(servenv.GRPCServer, ts)
}
})
}
55 changes: 55 additions & 0 deletions go/cmd/vtctldclient/commands.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package main

import (
"fmt"

"github.com/spf13/cobra"

vtctldatapb "vitess.io/vitess/go/vt/proto/vtctldata"
)

var (
getKeyspaceCmd = &cobra.Command{
Use: "GetKeyspace keyspace",
Aliases: []string{"getkeyspace"},
Args: cobra.ExactArgs(1),
RunE: commandGetKeyspace,
}
getKeyspacesCmd = &cobra.Command{
Use: "GetKeyspaces",
Aliases: []string{"getkeyspaces"},
Args: cobra.NoArgs,
RunE: commandGetKeyspaces,
}
)

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

if err != nil {
return err
}

fmt.Printf("%+v\n", resp.Keyspace)

return nil
}

func commandGetKeyspaces(cmd *cobra.Command, args []string) error {
resp, err := client.GetKeyspaces(commandCtx, &vtctldatapb.GetKeyspacesRequest{})
if err != nil {
return err
}

fmt.Printf("%+v\n", resp.Keyspaces)

return nil
}

func init() {
rootCmd.AddCommand(getKeyspaceCmd)
rootCmd.AddCommand(getKeyspacesCmd)
}
96 changes: 96 additions & 0 deletions go/cmd/vtctldclient/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
Copyright 2019 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 (
"context"
"errors"
"flag"
"io"
"os"
"time"

"github.com/spf13/cobra"

"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/trace"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/vtctl/vtctldclient"
)

var (
client vtctldclient.VtctldClient
traceCloser io.Closer
commandCtx context.Context
commandCancel func()

server string
actionTimeout time.Duration

// We use cobra to make subcommands easier to manage. And do a hack below
// in main to grab the rest of the flags globally scattered to make sure we
// pick up things like common servenv flags, tracing flags, etc. Refer to
// commands.go for all of the subcommands.
rootCmd = &cobra.Command{
// We use PersistentPreRun to set up the tracer, grpc client, and
// command context for every command.
PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) {
traceCloser = trace.StartTracing("vtctldclient")
if server == "" {
err = errors.New("please specify -server <vtctld_host:vtctld_port> to specify the vtctld server to connect to")
log.Error(err)
return err
}

client, err = vtctldclient.New("grpc", server)

commandCtx, commandCancel = context.WithTimeout(context.Background(), actionTimeout)
return err
},
// Similarly, PersistentPostRun cleans up the resources spawned by
// PersistentPreRun.
PersistentPostRunE: func(cmd *cobra.Command, args []string) error {
commandCancel()
err := client.Close()
trace.LogErrorsWhenClosing(traceCloser)
return err
},
TraverseChildren: true,
}
)

func main() {
defer exit.Recover()

// Grab all those global flags across the codebase and shove 'em on in.
rootCmd.PersistentFlags().AddGoFlagSet(flag.CommandLine)
// Attach our local flags
rootCmd.PersistentFlags().StringVar(&server, "server", "", "server to use for connection")
rootCmd.PersistentFlags().DurationVar(&actionTimeout, "action_timeout", time.Hour, "timeout for the total command")

// hack to get rid of an "ERROR: logging before flag.Parse"
args := os.Args[:]
os.Args = os.Args[:1]
flag.Parse()
os.Args = args

// back to your regularly scheduled cobra programming
if err := rootCmd.Execute(); err != nil {
log.Error(err)
exit.Return(1)
}
}
23 changes: 23 additions & 0 deletions go/cmd/vtctldclient/plugin_grpcvtctldclient.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Copyright 2019 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

// Imports and register the gRPC vtctld client.

import (
_ "vitess.io/vitess/go/vt/vtctl/grpcvtctldclient"
)
Loading