diff --git a/go/cmd/vtcombo/main.go b/go/cmd/vtcombo/main.go index b3e30c44960..30eca302d16 100644 --- a/go/cmd/vtcombo/main.go +++ b/go/cmd/vtcombo/main.go @@ -38,6 +38,7 @@ import ( "vitess.io/vitess/go/vt/srvtopo" "vitess.io/vitess/go/vt/topo" "vitess.io/vitess/go/vt/topo/memorytopo" + "vitess.io/vitess/go/vt/vtcombo" "vitess.io/vitess/go/vt/vtctld" "vitess.io/vitess/go/vt/vtgate" "vitess.io/vitess/go/vt/vttablet/tabletserver/tabletenv" @@ -109,7 +110,7 @@ func main() { servenv.OnClose(mysqld.Close) // tablets configuration and init - if err := initTabletMap(ts, tpb, mysqld, *dbcfgs, *schemaDir, mycnf); err != nil { + if err := vtcombo.InitTabletMap(ts, tpb, mysqld, *dbcfgs, *schemaDir, mycnf); err != nil { log.Errorf("initTabletMapProto failed: %v", err) exit.Return(1) } diff --git a/go/cmd/vtcombo/tablet_map.go b/go/vt/vtcombo/tablet_map.go similarity index 98% rename from go/cmd/vtcombo/tablet_map.go rename to go/vt/vtcombo/tablet_map.go index 3f2250c15fc..9fc9cfa36b4 100644 --- a/go/cmd/vtcombo/tablet_map.go +++ b/go/vt/vtcombo/tablet_map.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package vtcombo import ( "flag" @@ -71,9 +71,9 @@ type tablet struct { // tabletMap maps the tablet uid to the tablet record var tabletMap map[uint32]*tablet -// createTablet creates an individual tablet, with its agent, and adds +// CreateTablet creates an individual tablet, with its agent, and adds // it to the map. If it's a master tablet, it also issues a TER. -func createTablet(ctx context.Context, ts *topo.Server, cell string, uid uint32, keyspace, shard, dbname string, tabletType topodatapb.TabletType, mysqld mysqlctl.MysqlDaemon, dbcfgs dbconfigs.DBConfigs) error { +func CreateTablet(ctx context.Context, ts *topo.Server, cell string, uid uint32, keyspace, shard, dbname string, tabletType topodatapb.TabletType, mysqld mysqlctl.MysqlDaemon, dbcfgs dbconfigs.DBConfigs) error { alias := &topodatapb.TabletAlias{ Cell: cell, Uid: uid, @@ -104,9 +104,9 @@ func createTablet(ctx context.Context, ts *topo.Server, cell string, uid uint32, return nil } -// initTabletMap creates the action agents and associated data structures +// InitTabletMap creates the action agents and associated data structures // for all tablets, based on the vttest proto parameter. -func initTabletMap(ts *topo.Server, tpb *vttestpb.VTTestTopology, mysqld mysqlctl.MysqlDaemon, dbcfgs dbconfigs.DBConfigs, schemaDir string, mycnf *mysqlctl.Mycnf) error { +func InitTabletMap(ts *topo.Server, tpb *vttestpb.VTTestTopology, mysqld mysqlctl.MysqlDaemon, dbcfgs dbconfigs.DBConfigs, schemaDir string, mycnf *mysqlctl.Mycnf) error { tabletMap = make(map[uint32]*tablet) ctx := context.Background() @@ -183,7 +183,7 @@ func initTabletMap(ts *topo.Server, tpb *vttestpb.VTTestTopology, mysqld mysqlct replicas-- // create the master - if err := createTablet(ctx, ts, cell, uid, keyspace, shard, dbname, topodatapb.TabletType_MASTER, mysqld, dbcfgs); err != nil { + if err := CreateTablet(ctx, ts, cell, uid, keyspace, shard, dbname, topodatapb.TabletType_MASTER, mysqld, dbcfgs); err != nil { return err } uid++ @@ -191,7 +191,7 @@ func initTabletMap(ts *topo.Server, tpb *vttestpb.VTTestTopology, mysqld mysqlct for i := 0; i < replicas; i++ { // create a replica slave - if err := createTablet(ctx, ts, cell, uid, keyspace, shard, dbname, topodatapb.TabletType_REPLICA, mysqld, dbcfgs); err != nil { + if err := CreateTablet(ctx, ts, cell, uid, keyspace, shard, dbname, topodatapb.TabletType_REPLICA, mysqld, dbcfgs); err != nil { return err } uid++ @@ -199,7 +199,7 @@ func initTabletMap(ts *topo.Server, tpb *vttestpb.VTTestTopology, mysqld mysqlct for i := 0; i < rdonlys; i++ { // create a rdonly slave - if err := createTablet(ctx, ts, cell, uid, keyspace, shard, dbname, topodatapb.TabletType_RDONLY, mysqld, dbcfgs); err != nil { + if err := CreateTablet(ctx, ts, cell, uid, keyspace, shard, dbname, topodatapb.TabletType_RDONLY, mysqld, dbcfgs); err != nil { return err } uid++