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 <noblemittal@outlook.com>
  • Loading branch information
beingnoble03 committed Feb 15, 2025
1 parent 4c27ea8 commit ed0f3e9
Show file tree
Hide file tree
Showing 17 changed files with 4,640 additions and 3,127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@ import (
"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 +41,26 @@ var (
Aliases: []string{"materialize"},
Args: cobra.ExactArgs(1),
}

// addReferenceTables makes a MaterializeAddReferenceTables 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().MaterializeAddReferenceTables(common.GetCommandCtx(), &vtctldatapb.MaterializeAddReferenceTablesRequest{
Workflow: common.BaseOptions.Workflow,
Keyspace: common.BaseOptions.TargetKeyspace,
Tables: addReferenceTablesOptions.Tables,
})
return err
}

func registerCommands(root *cobra.Command) {
common.AddCommonFlags(base)
root.AddCommand(base)
Expand All @@ -54,6 +78,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 ed0f3e9

Please sign in to comment.