Skip to content

Commit

Permalink
VReplication: Add reference-tables to existing workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Noble Mittal <[email protected]>
  • Loading branch information
beingnoble03 committed Feb 17, 2025
1 parent 4c27ea8 commit 5b317c5
Show file tree
Hide file tree
Showing 18 changed files with 4,464 additions and 2,924 deletions.
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,31 @@ 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 {
_, err := common.GetClient().MaterializeAddTables(common.GetCommandCtx(), &vtctldatapb.MaterializeAddTablesRequest{
Workflow: common.BaseOptions.Workflow,
Keyspace: common.BaseOptions.TargetKeyspace,
Tables: addReferenceTablesOptions.Tables,
})
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 +84,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

0 comments on commit 5b317c5

Please sign in to comment.