本文整理汇总了Golang中github.com/youtube/vitess/go/vt/wrangler.Wrangler.InitTablet方法的典型用法代码示例。如果您正苦于以下问题:Golang Wrangler.InitTablet方法的具体用法?Golang Wrangler.InitTablet怎么用?Golang Wrangler.InitTablet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/youtube/vitess/go/vt/wrangler.Wrangler
的用法示例。
在下文中一共展示了Wrangler.InitTablet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewFakeTablet
// CreateTestTablet creates the test tablet in the topology. 'uid'
// has to be between 0 and 99. All the tablet info will be derived
// from that. Look at the implementation if you need values.
// Use TabletOption implementations if you need to change values at creation.
func NewFakeTablet(t *testing.T, wr *wrangler.Wrangler, cell string, uid uint32, tabletType topo.TabletType, options ...TabletOption) *FakeTablet {
if uid < 0 || uid > 99 {
t.Fatalf("uid has to be between 0 and 99: %v", uid)
}
state := topo.STATE_READ_ONLY
if tabletType == topo.TYPE_MASTER {
state = topo.STATE_READ_WRITE
}
tablet := &topo.Tablet{
Alias: topo.TabletAlias{Cell: cell, Uid: uid},
Hostname: fmt.Sprintf("%vhost", cell),
Portmap: map[string]int{
"vt": 8100 + int(uid),
"mysql": 3300 + int(uid),
"vts": 8200 + int(uid),
},
IPAddr: fmt.Sprintf("%v.0.0.1", 100+uid),
Keyspace: "test_keyspace",
Shard: "0",
Type: tabletType,
State: state,
}
for _, option := range options {
option(tablet)
}
if err := wr.InitTablet(tablet, false, true, false); err != nil {
t.Fatalf("cannot create tablet %v: %v", uid, err)
}
// create a FakeMysqlDaemon with the right information by default
fakeMysqlDaemon := &mysqlctl.FakeMysqlDaemon{}
if !tablet.Parent.IsZero() {
fakeMysqlDaemon.MasterAddr = fmt.Sprintf("%v.0.0.1:%v", 100+tablet.Parent.Uid, 3300+int(tablet.Parent.Uid))
}
fakeMysqlDaemon.MysqlPort = 3300 + int(uid)
return &FakeTablet{
Tablet: tablet,
FakeMysqlDaemon: fakeMysqlDaemon,
}
}
示例2: NewFakeTablet
// NewFakeTablet creates the test tablet in the topology. 'uid'
// has to be between 0 and 99. All the tablet info will be derived
// from that. Look at the implementation if you need values.
// Use TabletOption implementations if you need to change values at creation.
func NewFakeTablet(t *testing.T, wr *wrangler.Wrangler, cell string, uid uint32, tabletType topodatapb.TabletType, db *fakesqldb.DB, options ...TabletOption) *FakeTablet {
if uid < 0 || uid > 99 {
t.Fatalf("uid has to be between 0 and 99: %v", uid)
}
tablet := &topodatapb.Tablet{
Alias: &topodatapb.TabletAlias{Cell: cell, Uid: uid},
Hostname: fmt.Sprintf("%vhost", cell),
PortMap: map[string]int32{
"vt": int32(8100 + uid),
"mysql": int32(3300 + uid),
"grpc": int32(8200 + uid),
},
Ip: fmt.Sprintf("%v.0.0.1", 100+uid),
Keyspace: "test_keyspace",
Shard: "0",
Type: tabletType,
}
for _, option := range options {
option(tablet)
}
_, startHTTPServer := tablet.PortMap["start_http_server"]
delete(tablet.PortMap, "start_http_server")
_, force := tablet.PortMap["force_init"]
delete(tablet.PortMap, "force_init")
if err := wr.InitTablet(context.Background(), tablet, force, false, true, false); err != nil {
t.Fatalf("cannot create tablet %v: %v", uid, err)
}
// create a FakeMysqlDaemon with the right information by default
fakeMysqlDaemon := mysqlctl.NewFakeMysqlDaemon(db)
fakeMysqlDaemon.MysqlPort = 3300 + int32(uid)
return &FakeTablet{
Tablet: tablet,
FakeMysqlDaemon: fakeMysqlDaemon,
StartHTTPServer: startHTTPServer,
}
}
示例3: NewFakeTablet
// NewFakeTablet creates the test tablet in the topology. 'uid'
// has to be between 0 and 99. All the tablet info will be derived
// from that. Look at the implementation if you need values.
// Use TabletOption implementations if you need to change values at creation.
func NewFakeTablet(t *testing.T, wr *wrangler.Wrangler, cell string, uid uint32, tabletType topo.TabletType, options ...TabletOption) *FakeTablet {
if uid < 0 || uid > 99 {
t.Fatalf("uid has to be between 0 and 99: %v", uid)
}
tablet := &topo.Tablet{
Alias: topo.TabletAlias{Cell: cell, Uid: uid},
Hostname: fmt.Sprintf("%vhost", cell),
Portmap: map[string]int{
"vt": 8100 + int(uid),
"mysql": 3300 + int(uid),
"vts": 8200 + int(uid),
},
IPAddr: fmt.Sprintf("%v.0.0.1", 100+uid),
Keyspace: "test_keyspace",
Shard: "0",
Type: tabletType,
}
for _, option := range options {
option(tablet)
}
delete(tablet.Portmap, "parent_uid")
_, force := tablet.Portmap["force_init"]
delete(tablet.Portmap, "force_init")
if err := wr.InitTablet(context.Background(), tablet, force, true, false); err != nil {
t.Fatalf("cannot create tablet %v: %v", uid, err)
}
// create a FakeMysqlDaemon with the right information by default
fakeMysqlDaemon := mysqlctl.NewFakeMysqlDaemon()
fakeMysqlDaemon.MysqlPort = 3300 + int(uid)
return &FakeTablet{
Tablet: tablet,
FakeMysqlDaemon: fakeMysqlDaemon,
}
}