本文整理汇总了Golang中github.com/youtube/vitess/go/sqltypes.ResultStream.Recv方法的典型用法代码示例。如果您正苦于以下问题:Golang ResultStream.Recv方法的具体用法?Golang ResultStream.Recv怎么用?Golang ResultStream.Recv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/youtube/vitess/go/sqltypes.ResultStream
的用法示例。
在下文中一共展示了ResultStream.Recv方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getStreamError
func getStreamError(stream sqltypes.ResultStream, err error) error {
if err != nil {
return err
}
for {
_, err := stream.Recv()
switch err {
case nil:
// keep going
case io.EOF:
return nil
default:
return err
}
}
}
示例2: processOneStreamingResult
func (stc *ScatterConn) processOneStreamingResult(mu *sync.Mutex, stream sqltypes.ResultStream, err error, replyErr *error, fieldSent *bool, sendReply func(reply *sqltypes.Result) error) error {
if err != nil {
return err
}
for {
qr, err := stream.Recv()
if err != nil {
if err == io.EOF {
return nil
}
return err
}
mu.Lock()
if *replyErr != nil {
mu.Unlock()
// we had an error sending results, drain input
for {
if _, err := stream.Recv(); err != nil {
break
}
}
return nil
}
// only send field info once for scattered streaming
if len(qr.Fields) > 0 && len(qr.Rows) == 0 {
if *fieldSent {
mu.Unlock()
continue
}
*fieldSent = true
}
*replyErr = sendReply(qr)
mu.Unlock()
}
}
示例3: testEchoStreamExecute
func testEchoStreamExecute(t *testing.T, conn *vtgateconn.VTGateConn) {
var stream sqltypes.ResultStream
var err error
var qr *sqltypes.Result
ctx := callerid.NewContext(context.Background(), callerID, nil)
stream, err = conn.StreamExecute(ctx, echoPrefix+query, bindVars, tabletType)
if err != nil {
t.Fatal(err)
}
qr, err = stream.Recv()
checkEcho(t, "StreamExecute", qr, err, map[string]string{
"callerId": callerIDEcho,
"query": echoPrefix + query,
"bindVars": bindVarsEcho,
"tabletType": tabletTypeEcho,
})
stream, err = conn.StreamExecuteShards(ctx, echoPrefix+query, keyspace, shards, bindVars, tabletType)
if err != nil {
t.Fatal(err)
}
qr, err = stream.Recv()
checkEcho(t, "StreamExecuteShards", qr, err, map[string]string{
"callerId": callerIDEcho,
"query": echoPrefix + query,
"keyspace": keyspace,
"shards": shardsEcho,
"bindVars": bindVarsEcho,
"tabletType": tabletTypeEcho,
})
stream, err = conn.StreamExecuteKeyspaceIds(ctx, echoPrefix+query, keyspace, keyspaceIDs, bindVars, tabletType)
if err != nil {
t.Fatal(err)
}
qr, err = stream.Recv()
checkEcho(t, "StreamExecuteKeyspaceIds", qr, err, map[string]string{
"callerId": callerIDEcho,
"query": echoPrefix + query,
"keyspace": keyspace,
"keyspaceIds": keyspaceIDsEcho,
"bindVars": bindVarsEcho,
"tabletType": tabletTypeEcho,
})
stream, err = conn.StreamExecuteKeyRanges(ctx, echoPrefix+query, keyspace, keyRanges, bindVars, tabletType)
if err != nil {
t.Fatal(err)
}
qr, err = stream.Recv()
checkEcho(t, "StreamExecuteKeyRanges", qr, err, map[string]string{
"callerId": callerIDEcho,
"query": echoPrefix + query,
"keyspace": keyspace,
"keyRanges": keyRangesEcho,
"bindVars": bindVarsEcho,
"tabletType": tabletTypeEcho,
})
}