本文整理汇总了Golang中github.com/youtube/vitess/go/vt/vtgate/vtgateconn.VTGateConn.StreamExecuteShard方法的典型用法代码示例。如果您正苦于以下问题:Golang VTGateConn.StreamExecuteShard方法的具体用法?Golang VTGateConn.StreamExecuteShard怎么用?Golang VTGateConn.StreamExecuteShard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/youtube/vitess/go/vt/vtgate/vtgateconn.VTGateConn
的用法示例。
在下文中一共展示了VTGateConn.StreamExecuteShard方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: testStreamExecuteShardPanic
func testStreamExecuteShardPanic(t *testing.T, conn *vtgateconn.VTGateConn) {
ctx := context.Background()
execCase := execMap["request1"]
packets, errFunc := conn.StreamExecuteShard(ctx, execCase.shardQuery.Sql, execCase.shardQuery.Keyspace, execCase.shardQuery.Shards, execCase.execQuery.BindVariables, execCase.execQuery.TabletType)
if _, ok := <-packets; ok {
t.Fatalf("Received packets instead of panic?")
}
err := errFunc()
expectPanic(t, err)
}
示例2: testStreamExecuteShard
func testStreamExecuteShard(t *testing.T, conn *vtgateconn.VTGateConn) {
ctx := context.Background()
execCase := execMap["request1"]
packets, errFunc := conn.StreamExecuteShard(ctx, execCase.shardQuery.Sql, execCase.shardQuery.Keyspace, execCase.shardQuery.Shards, execCase.execQuery.BindVariables, execCase.execQuery.TabletType)
var qr mproto.QueryResult
for packet := range packets {
if len(packet.Fields) != 0 {
qr.Fields = packet.Fields
}
if len(packet.Rows) != 0 {
qr.Rows = append(qr.Rows, packet.Rows...)
}
}
wantResult := *execCase.reply.Result
wantResult.RowsAffected = 0
wantResult.InsertId = 0
if !reflect.DeepEqual(qr, wantResult) {
t.Errorf("Unexpected result from Execute: got %+v want %+v", qr, wantResult)
}
err := errFunc()
if err != nil {
t.Error(err)
}
packets, errFunc = conn.StreamExecuteShard(ctx, "none", "", []string{}, nil, "")
for packet := range packets {
t.Errorf("packet: %+v, want none", packet)
}
err = errFunc()
want := "no match for: none"
if err == nil || !strings.Contains(err.Error(), want) {
t.Errorf("none request: %v, want %v", err, want)
}
execCase = execMap["errorRequst"]
packets, errFunc = conn.StreamExecuteShard(ctx, execCase.shardQuery.Sql, execCase.shardQuery.Keyspace, execCase.shardQuery.Shards, execCase.execQuery.BindVariables, execCase.execQuery.TabletType)
for packet := range packets {
t.Errorf("packet: %+v, want none", packet)
}
err = errFunc()
want = "app error"
if err == nil || !strings.Contains(err.Error(), want) {
t.Errorf("errorRequst: %v, want %v", err, want)
}
}