本文整理汇总了Golang中github.com/youtube/vitess/go/vt/tabletserver/tabletconn.TabletConn.UpdateStream方法的典型用法代码示例。如果您正苦于以下问题:Golang TabletConn.UpdateStream方法的具体用法?Golang TabletConn.UpdateStream怎么用?Golang TabletConn.UpdateStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/youtube/vitess/go/vt/tabletserver/tabletconn.TabletConn
的用法示例。
在下文中一共展示了TabletConn.UpdateStream方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: testUpdateStreamError
func testUpdateStreamError(t *testing.T, conn tabletconn.TabletConn, f *FakeQueryService) {
t.Log("testUpdateStreamError")
f.HasError = true
testErrorHelper(t, f, "UpdateStream", func(ctx context.Context) error {
f.ErrorWait = make(chan struct{})
ctx = callerid.NewContext(ctx, TestCallerID, TestVTGateCallerID)
stream, err := conn.UpdateStream(ctx, TestTarget, UpdateStreamPosition, UpdateStreamTimestamp)
if err != nil {
t.Fatalf("UpdateStream failed: %v", err)
}
qr, err := stream.Recv()
if err != nil {
t.Fatalf("UpdateStream failed: cannot read result1: %v", err)
}
if !reflect.DeepEqual(*qr, UpdateStreamStreamEvent1) {
t.Errorf("Unexpected result1 from UpdateStream: got %v wanted %v", qr, UpdateStreamStreamEvent1)
}
// signal to the server that the first result has been received
close(f.ErrorWait)
// After 1 result, we expect to get an error (no more results).
qr, err = stream.Recv()
if err == nil {
t.Fatalf("UpdateStream channel wasn't closed")
}
return err
})
f.HasError = false
}
示例2: testUpdateStream
func testUpdateStream(t *testing.T, conn tabletconn.TabletConn, f *FakeQueryService) {
t.Log("testUpdateStream")
ctx := context.Background()
ctx = callerid.NewContext(ctx, TestCallerID, TestVTGateCallerID)
stream, err := conn.UpdateStream(ctx, TestTarget, UpdateStreamPosition, UpdateStreamTimestamp)
if err != nil {
t.Fatalf("UpdateStream failed: %v", err)
}
qr, err := stream.Recv()
if err != nil {
t.Fatalf("UpdateStream failed: cannot read result1: %v", err)
}
if !reflect.DeepEqual(*qr, UpdateStreamStreamEvent1) {
t.Errorf("Unexpected result1 from UpdateStream: got %v wanted %v", qr, UpdateStreamStreamEvent1)
}
qr, err = stream.Recv()
if err != nil {
t.Fatalf("UpdateStream failed: cannot read result2: %v", err)
}
if !reflect.DeepEqual(*qr, UpdateStreamStreamEvent2) {
t.Errorf("Unexpected result2 from UpdateStream: got %v wanted %v", qr, UpdateStreamStreamEvent2)
}
qr, err = stream.Recv()
if err != io.EOF {
t.Fatalf("UpdateStream errFunc failed: %v", err)
}
}
示例3: testUpdateStreamPanics
func testUpdateStreamPanics(t *testing.T, conn tabletconn.TabletConn, f *FakeQueryService) {
t.Log("testUpdateStreamPanics")
// early panic is before sending the Fields, that is returned
// by the UpdateStream call itself, or as the first error
// by ErrFunc
f.UpdateStreamPanicsEarly = true
testPanicHelper(t, f, "UpdateStream.Early", func(ctx context.Context) error {
ctx = callerid.NewContext(ctx, TestCallerID, TestVTGateCallerID)
stream, err := conn.UpdateStream(ctx, TestTarget, UpdateStreamPosition, UpdateStreamTimestamp)
if err != nil {
return err
}
_, err = stream.Recv()
return err
})
// late panic is after sending Fields
f.UpdateStreamPanicsEarly = false
testPanicHelper(t, f, "UpdateStream.Late", func(ctx context.Context) error {
f.PanicWait = make(chan struct{})
ctx = callerid.NewContext(ctx, TestCallerID, TestVTGateCallerID)
stream, err := conn.UpdateStream(ctx, TestTarget, UpdateStreamPosition, UpdateStreamTimestamp)
if err != nil {
t.Fatalf("UpdateStream failed: %v", err)
}
qr, err := stream.Recv()
if err != nil {
t.Fatalf("UpdateStream failed: cannot read result1: %v", err)
}
if !reflect.DeepEqual(*qr, UpdateStreamStreamEvent1) {
t.Errorf("Unexpected result1 from UpdateStream: got %v wanted %v", qr, UpdateStreamStreamEvent1)
}
close(f.PanicWait)
_, err = stream.Recv()
return err
})
}