本文整理汇总了Golang中github.com/youtube/vitess/go/vt/topo.Server.UpdateKeyspace方法的典型用法代码示例。如果您正苦于以下问题:Golang Server.UpdateKeyspace方法的具体用法?Golang Server.UpdateKeyspace怎么用?Golang Server.UpdateKeyspace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/youtube/vitess/go/vt/topo.Server
的用法示例。
在下文中一共展示了Server.UpdateKeyspace方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: CheckKeyspace
func CheckKeyspace(t *testing.T, ts topo.Server) {
keyspaces, err := ts.GetKeyspaces()
if err != nil {
t.Errorf("GetKeyspaces(empty): %v", err)
}
if len(keyspaces) != 0 {
t.Errorf("len(GetKeyspaces()) != 0: %v", keyspaces)
}
if err := ts.CreateKeyspace("test_keyspace", &topo.Keyspace{}); err != nil {
t.Errorf("CreateKeyspace: %v", err)
}
if err := ts.CreateKeyspace("test_keyspace", &topo.Keyspace{}); err != topo.ErrNodeExists {
t.Errorf("CreateKeyspace(again) is not ErrNodeExists: %v", err)
}
keyspaces, err = ts.GetKeyspaces()
if err != nil {
t.Errorf("GetKeyspaces: %v", err)
}
if len(keyspaces) != 1 || keyspaces[0] != "test_keyspace" {
t.Errorf("GetKeyspaces: want %v, got %v", []string{"test_keyspace"}, keyspaces)
}
if err := ts.CreateKeyspace("test_keyspace2", &topo.Keyspace{
ShardingColumnName: "user_id",
ShardingColumnType: key.KIT_UINT64,
ServedFrom: map[topo.TabletType]string{
topo.TYPE_MASTER: "test_keyspace3",
},
}); err != nil {
t.Errorf("CreateKeyspace: %v", err)
}
keyspaces, err = ts.GetKeyspaces()
if err != nil {
t.Errorf("GetKeyspaces: %v", err)
}
if len(keyspaces) != 2 ||
keyspaces[0] != "test_keyspace" ||
keyspaces[1] != "test_keyspace2" {
t.Errorf("GetKeyspaces: want %v, got %v", []string{"test_keyspace", "test_keyspace2"}, keyspaces)
}
ki, err := ts.GetKeyspace("test_keyspace2")
if err != nil {
t.Fatalf("GetKeyspace: %v", err)
}
if ki.ShardingColumnName != "user_id" ||
ki.ShardingColumnType != key.KIT_UINT64 ||
ki.ServedFrom[topo.TYPE_MASTER] != "test_keyspace3" {
t.Errorf("GetKeyspace: unexpected keyspace, got %v", *ki)
}
ki.ShardingColumnName = "other_id"
ki.ShardingColumnType = key.KIT_BYTES
delete(ki.ServedFrom, topo.TYPE_MASTER)
ki.ServedFrom[topo.TYPE_REPLICA] = "test_keyspace4"
err = ts.UpdateKeyspace(ki)
if err != nil {
t.Fatalf("UpdateKeyspace: %v", err)
}
ki, err = ts.GetKeyspace("test_keyspace2")
if err != nil {
t.Fatalf("GetKeyspace: %v", err)
}
if ki.ShardingColumnName != "other_id" ||
ki.ShardingColumnType != key.KIT_BYTES ||
ki.ServedFrom[topo.TYPE_REPLICA] != "test_keyspace4" {
t.Errorf("GetKeyspace: unexpected keyspace, got %v", *ki)
}
}