Skip to content

Commit

Permalink
Reimplement {Apply,Get}RoutingRules, RebuildVSchemaGraph vtctl co…
Browse files Browse the repository at this point in the history
…mmands using VtctldServer

Signed-off-by: Andrew Mason <[email protected]>
  • Loading branch information
ajm188 committed Jun 1, 2021
1 parent c5d045c commit 3d2ac4a
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions go/vt/vtctl/vtctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3108,11 +3108,12 @@ func commandGetVSchema(ctx context.Context, wr *wrangler.Wrangler, subFlags *fla
}

func commandGetRoutingRules(ctx context.Context, wr *wrangler.Wrangler, subFlags *flag.FlagSet, args []string) error {
rr, err := wr.TopoServer().GetRoutingRules(ctx)
resp, err := wr.VtctldServer().GetRoutingRules(ctx, &vtctldatapb.GetRoutingRulesRequest{})
if err != nil {
return err
}
b, err := json2.MarshalIndentPB(rr, " ")

b, err := json2.MarshalIndentPB(resp.RoutingRules, " ")
if err != nil {
wr.Logger().Printf("%v\n", err)
return err
Expand All @@ -3132,7 +3133,10 @@ func commandRebuildVSchemaGraph(ctx context.Context, wr *wrangler.Wrangler, subF
return fmt.Errorf("RebuildVSchemaGraph doesn't take any arguments")
}

return wr.TopoServer().RebuildSrvVSchema(ctx, cells)
_, err := wr.VtctldServer().RebuildVSchemaGraph(ctx, &vtctldatapb.RebuildVSchemaGraphRequest{
Cells: cells,
})
return err
}

func commandApplyVSchema(ctx context.Context, wr *wrangler.Wrangler, subFlags *flag.FlagSet, args []string) error {
Expand Down Expand Up @@ -3286,15 +3290,12 @@ func commandApplyRoutingRules(ctx context.Context, wr *wrangler.Wrangler, subFla
wr.Logger().Printf("New RoutingRules object:\n%s\nIf this is not what you expected, check the input data (as JSON parsing will skip unexpected fields).\n", b)
}

if err := wr.TopoServer().SaveRoutingRules(ctx, rr); err != nil {
return err
}

if *skipRebuild {
wr.Logger().Warningf("Skipping rebuild of SrvVSchema, will need to run RebuildVSchemaGraph for changes to take effect")
return nil
}
return wr.TopoServer().RebuildSrvVSchema(ctx, cells)
_, err = wr.VtctldServer().ApplyRoutingRules(ctx, &vtctldatapb.ApplyRoutingRulesRequest{
RoutingRules: rr,
SkipRebuild: *skipRebuild,
RebuildCells: cells,
})
return err
}

func commandGetSrvKeyspaceNames(ctx context.Context, wr *wrangler.Wrangler, subFlags *flag.FlagSet, args []string) error {
Expand Down

0 comments on commit 3d2ac4a

Please sign in to comment.