本文整理匯總了Golang中github.com/youtube/vitess/go/vt/topo.Impl.DeleteShardReplication方法的典型用法代碼示例。如果您正苦於以下問題:Golang Impl.DeleteShardReplication方法的具體用法?Golang Impl.DeleteShardReplication怎麽用?Golang Impl.DeleteShardReplication使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/youtube/vitess/go/vt/topo.Impl
的用法示例。
在下文中一共展示了Impl.DeleteShardReplication方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: checkShardReplication
// checkShardReplication tests ShardReplication objects
func checkShardReplication(t *testing.T, ts topo.Impl) {
ctx := context.Background()
cell := getLocalCell(ctx, t, ts)
if _, err := ts.GetShardReplication(ctx, cell, "test_keyspace", "-10"); err != topo.ErrNoNode {
t.Errorf("GetShardReplication(not there): %v", err)
}
sr := &topodatapb.ShardReplication{
Nodes: []*topodatapb.ShardReplication_Node{
{
TabletAlias: &topodatapb.TabletAlias{
Cell: "c1",
Uid: 1,
},
},
},
}
if err := ts.UpdateShardReplicationFields(ctx, cell, "test_keyspace", "-10", func(oldSr *topodatapb.ShardReplication) error {
return topo.ErrNoUpdateNeeded
}); err != nil {
t.Fatalf("UpdateShardReplicationFields() failed: %v", err)
}
if err := ts.UpdateShardReplicationFields(ctx, cell, "test_keyspace", "-10", func(oldSr *topodatapb.ShardReplication) error {
*oldSr = *sr
return nil
}); err != nil {
t.Fatalf("UpdateShardReplicationFields() failed: %v", err)
}
if sri, err := ts.GetShardReplication(ctx, cell, "test_keyspace", "-10"); err != nil {
t.Errorf("GetShardReplication(new guy) failed: %v", err)
} else {
if len(sri.Nodes) != 1 ||
sri.Nodes[0].TabletAlias.Cell != "c1" ||
sri.Nodes[0].TabletAlias.Uid != 1 {
t.Errorf("GetShardReplication(new guy) returned wrong value: %v", *sri)
}
}
if err := ts.UpdateShardReplicationFields(ctx, cell, "test_keyspace", "-10", func(sr *topodatapb.ShardReplication) error {
sr.Nodes = append(sr.Nodes, &topodatapb.ShardReplication_Node{
TabletAlias: &topodatapb.TabletAlias{
Cell: "c3",
Uid: 3,
},
})
return nil
}); err != nil {
t.Errorf("UpdateShardReplicationFields() failed: %v", err)
}
if sri, err := ts.GetShardReplication(ctx, cell, "test_keyspace", "-10"); err != nil {
t.Errorf("GetShardReplication(after append) failed: %v", err)
} else {
if len(sri.Nodes) != 2 ||
sri.Nodes[0].TabletAlias.Cell != "c1" ||
sri.Nodes[0].TabletAlias.Uid != 1 ||
sri.Nodes[1].TabletAlias.Cell != "c3" ||
sri.Nodes[1].TabletAlias.Uid != 3 {
t.Errorf("GetShardReplication(new guy) returned wrong value: %v", *sri)
}
}
if err := ts.DeleteShardReplication(ctx, cell, "test_keyspace", "-10"); err != nil {
t.Errorf("DeleteShardReplication(existing) failed: %v", err)
}
if err := ts.DeleteShardReplication(ctx, cell, "test_keyspace", "-10"); err != topo.ErrNoNode {
t.Errorf("DeleteShardReplication(again) returned: %v", err)
}
if err := ts.DeleteKeyspaceReplication(ctx, cell, "test_keyspace"); err != nil {
t.Errorf("DeleteKeyspaceReplication(existing) failed: %v", err)
}
if err := ts.DeleteKeyspaceReplication(ctx, cell, "test_keyspace"); err != topo.ErrNoNode {
t.Errorf("DeleteKeyspaceReplication(again) returned: %v", err)
}
}