Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,22 @@ package materialize

import (
"fmt"
"strings"

"github.com/spf13/cobra"

"vitess.io/vitess/go/cmd/vtctldclient/command/vreplication/common"
"vitess.io/vitess/go/mysql/config"
"vitess.io/vitess/go/vt/topo/topoproto"

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

var (
addReferenceTablesOptions = struct {
Tables []string
}{}

// base is the base command for all actions related to Materialize.
base = &cobra.Command{
Use: "Materialize --workflow <workflow> --target-keyspace <keyspace> [command] [command-flags]",
Expand All @@ -35,8 +42,39 @@ var (
Aliases: []string{"materialize"},
Args: cobra.ExactArgs(1),
}

// addReferenceTables makes a MaterializeAddTables gRPC call to a vtctld.
addReferenceTables = &cobra.Command{
Use: "add-reference-tables --tables='table1,table2'",
Short: "Add reference tables to the existing materialize workflow",
Aliases: []string{"Add-Reference-Tables"},
Args: cobra.NoArgs,
RunE: commandAddReferenceTables,
}
)

func commandAddReferenceTables(cmd *cobra.Command, args []string) error {
tableSettings := []*vtctldatapb.TableMaterializeSettings{}
for _, table := range addReferenceTablesOptions.Tables {
tableSettings = append(tableSettings, &vtctldatapb.TableMaterializeSettings{
TargetTable: table,
})
}

_, err := common.GetClient().MaterializeAddTables(common.GetCommandCtx(), &vtctldatapb.MaterializeAddTablesRequest{
Workflow: common.BaseOptions.Workflow,
Keyspace: common.BaseOptions.TargetKeyspace,
TableSettings: tableSettings,
})

if err != nil {
return err
}
fmt.Printf("Reference table(s) %s added to the workflow %s. Use show to view the status.\n",
strings.Join(addReferenceTablesOptions.Tables, ", "), common.BaseOptions.Workflow)
return nil
}

func registerCommands(root *cobra.Command) {
common.AddCommonFlags(base)
root.AddCommand(base)
Expand All @@ -54,6 +92,10 @@ func registerCommands(root *cobra.Command) {
create.Flags().StringSliceVarP(&common.CreateOptions.ReferenceTables, "reference-tables", "r", nil, "Used to specify the reference tables to materialize on every target shard.")
base.AddCommand(create)

addReferenceTables.Flags().StringSliceVar(&addReferenceTablesOptions.Tables, "tables", nil, "Used to specify the reference tables to be added to the existing workflow")
addReferenceTables.MarkFlagRequired("tables")
base.AddCommand(addReferenceTables)

// Generic workflow commands.
opts := &common.SubCommandsOpts{
SubCommand: "Materialize",
Expand Down
619 changes: 317 additions & 302 deletions go/vt/proto/tabletmanagerdata/tabletmanagerdata.pb.go

Large diffs are not rendered by default.

59 changes: 59 additions & 0 deletions go/vt/proto/tabletmanagerdata/tabletmanagerdata_vtproto.pb.go

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

Loading
Loading