本文整理汇总了Golang中github.com/youtube/vitess/go/sqltypes.ResultStream类的典型用法代码示例。如果您正苦于以下问题:Golang ResultStream类的具体用法?Golang ResultStream怎么用?Golang ResultStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ResultStream类的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
}
}
}
开发者ID:xujianhai,项目名称:vitess,代码行数:16,代码来源:errors.go
示例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()
}
}
开发者ID:aaijazi,项目名称:vitess,代码行数:37,代码来源:scatter_conn.go
示例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,
})
}
开发者ID:aaijazi,项目名称:vitess,代码行数:61,代码来源:echo.go
注:本文中的github.com/youtube/vitess/go/sqltypes.ResultStream类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论