本文整理汇总了Golang中github.com/youtube/vitess/go/vt/tabletserver/tabletconn.TabletConn类的典型用法代码示例。如果您正苦于以下问题:Golang TabletConn类的具体用法?Golang TabletConn怎么用?Golang TabletConn使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TabletConn类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: testStreamExecuteError
func testStreamExecuteError(t *testing.T, conn tabletconn.TabletConn, f *FakeQueryService) {
t.Log("testStreamExecuteError")
f.HasError = true
testErrorHelper(t, f, "StreamExecute", func(ctx context.Context) error {
f.ErrorWait = make(chan struct{})
ctx = callerid.NewContext(ctx, TestCallerID, TestVTGateCallerID)
stream, err := conn.StreamExecute(ctx, TestTarget, StreamExecuteQuery, StreamExecuteBindVars)
if err != nil {
t.Fatalf("StreamExecute failed: %v", err)
}
qr, err := stream.Recv()
if err != nil {
t.Fatalf("StreamExecute failed: cannot read result1: %v", err)
}
if len(qr.Rows) == 0 {
qr.Rows = nil
}
if !reflect.DeepEqual(*qr, StreamExecuteQueryResult1) {
t.Errorf("Unexpected result1 from StreamExecute: got %v wanted %v", qr, StreamExecuteQueryResult1)
}
// 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("StreamExecute channel wasn't closed")
}
return err
})
f.HasError = false
}
开发者ID:jmptrader,项目名称:vitess,代码行数:31,代码来源:tabletconntest.go
示例2: testSplitQueryPanics
func testSplitQueryPanics(t *testing.T, conn tabletconn.TabletConn) {
t.Log("testSplitQueryPanics")
ctx := context.Background()
if _, err := conn.SplitQuery(ctx, splitQueryBoundQuery, splitQuerySplitColumn, splitQuerySplitCount); err == nil || !strings.Contains(err.Error(), "caught test panic") {
t.Fatalf("unexpected panic error: %v", err)
}
}
开发者ID:payintel,项目名称:vitess,代码行数:7,代码来源:tabletconntest.go
示例3: testExecuteBatchPanics
func testExecuteBatchPanics(t *testing.T, conn tabletconn.TabletConn, f *FakeQueryService) {
t.Log("testExecuteBatchPanics")
testPanicHelper(t, f, "ExecuteBatch", func(ctx context.Context) error {
_, err := conn.ExecuteBatch(ctx, TestTarget, ExecuteBatchQueries, TestAsTransaction, ExecuteBatchTransactionID)
return err
})
}
开发者ID:jmptrader,项目名称:vitess,代码行数:7,代码来源:tabletconntest.go
示例4: testStreamExecute2Error
func testStreamExecute2Error(t *testing.T, conn tabletconn.TabletConn) {
t.Log("testStreamExecute2Error")
ctx := context.Background()
stream, errFunc, err := conn.StreamExecute2(ctx, streamExecuteQuery, streamExecuteBindVars, streamExecuteTransactionID)
if err != nil {
t.Fatalf("StreamExecute2 failed: %v", err)
}
qr, ok := <-stream
if !ok {
t.Fatalf("StreamExecute2 failed: cannot read result1")
}
if len(qr.Rows) == 0 {
qr.Rows = nil
}
if !reflect.DeepEqual(*qr, streamExecuteQueryResult1) {
t.Errorf("Unexpected result1 from StreamExecute2: got %v wanted %v", qr, streamExecuteQueryResult1)
}
// signal to the server that the first result has been received
close(errorWait)
// After 1 result, we expect to get an error (no more results).
qr, ok = <-stream
if ok {
t.Fatalf("StreamExecute2 channel wasn't closed")
}
err = errFunc()
if err == nil {
t.Fatalf("StreamExecute2 was expecting an error, didn't get one")
}
if !strings.Contains(err.Error(), expectedErrMatch) {
t.Errorf("Unexpected error from StreamExecute2: got %v, wanted err containing %v", err, expectedErrMatch)
}
// reset state for the test
errorWait = make(chan struct{})
}
开发者ID:pranjal5215,项目名称:vitess,代码行数:34,代码来源:tabletconntest.go
示例5: 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
}
开发者ID:dumbunny,项目名称:vitess,代码行数:28,代码来源:tabletconntest.go
示例6: 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)
}
}
开发者ID:dumbunny,项目名称:vitess,代码行数:27,代码来源:tabletconntest.go
示例7: testStreamExecute
func testStreamExecute(t *testing.T, conn tabletconn.TabletConn, f *FakeQueryService) {
t.Log("testStreamExecute")
ctx := context.Background()
ctx = callerid.NewContext(ctx, TestCallerID, TestVTGateCallerID)
stream, err := conn.StreamExecute(ctx, TestTarget, StreamExecuteQuery, StreamExecuteBindVars)
if err != nil {
t.Fatalf("StreamExecute failed: %v", err)
}
qr, err := stream.Recv()
if err != nil {
t.Fatalf("StreamExecute failed: cannot read result1: %v", err)
}
if len(qr.Rows) == 0 {
qr.Rows = nil
}
if !reflect.DeepEqual(*qr, StreamExecuteQueryResult1) {
t.Errorf("Unexpected result1 from StreamExecute: got %v wanted %v", qr, StreamExecuteQueryResult1)
}
qr, err = stream.Recv()
if err != nil {
t.Fatalf("StreamExecute failed: cannot read result2: %v", err)
}
if len(qr.Fields) == 0 {
qr.Fields = nil
}
if !reflect.DeepEqual(*qr, StreamExecuteQueryResult2) {
t.Errorf("Unexpected result2 from StreamExecute: got %v wanted %v", qr, StreamExecuteQueryResult2)
}
qr, err = stream.Recv()
if err != io.EOF {
t.Fatalf("StreamExecute errFunc failed: %v", err)
}
}
开发者ID:jmptrader,项目名称:vitess,代码行数:33,代码来源:tabletconntest.go
示例8: testBegin2Panics
func testBegin2Panics(t *testing.T, conn tabletconn.TabletConn) {
t.Log("testBegin2Panics")
ctx := context.Background()
if _, err := conn.Begin2(ctx); err == nil || !strings.Contains(err.Error(), "caught test panic") {
t.Fatalf("unexpected panic error: %v", err)
}
}
开发者ID:payintel,项目名称:vitess,代码行数:7,代码来源:tabletconntest.go
示例9: testRollback
func testRollback(t *testing.T, conn tabletconn.TabletConn) {
ctx := context.Background()
err := conn.Rollback(ctx, rollbackTransactionID)
if err != nil {
t.Fatalf("Rollback failed: %v", err)
}
}
开发者ID:tjyang,项目名称:vitess,代码行数:7,代码来源:tabletconntest.go
示例10: testSplitQueryPanics
func testSplitQueryPanics(t *testing.T, conn tabletconn.TabletConn, f *FakeQueryService) {
t.Log("testSplitQueryPanics")
testPanicHelper(t, f, "SplitQuery", func(ctx context.Context) error {
_, err := conn.SplitQuery(ctx, TestTarget, SplitQueryBoundQuery, SplitQuerySplitColumn, SplitQuerySplitCount)
return err
})
}
开发者ID:jmptrader,项目名称:vitess,代码行数:7,代码来源:tabletconntest.go
示例11: testCommit
func testCommit(t *testing.T, conn tabletconn.TabletConn) {
ctx := context.Background()
err := conn.Commit(ctx, commitTransactionID)
if err != nil {
t.Fatalf("Commit failed: %v", err)
}
}
开发者ID:tjyang,项目名称:vitess,代码行数:7,代码来源:tabletconntest.go
示例12: testReadTransactionPanics
func testReadTransactionPanics(t *testing.T, conn tabletconn.TabletConn, f *FakeQueryService) {
t.Log("testReadTransactionPanics")
testPanicHelper(t, f, "ReadTransaction", func(ctx context.Context) error {
_, err := conn.ReadTransaction(ctx, TestTarget, Dtid)
return err
})
}
开发者ID:dumbunny,项目名称:vitess,代码行数:7,代码来源:tabletconntest.go
示例13: testStreamExecute
func testStreamExecute(t *testing.T, conn tabletconn.TabletConn) {
t.Log("testStreamExecute")
ctx := context.Background()
stream, errFunc, err := conn.StreamExecute(ctx, streamExecuteQuery, streamExecuteBindVars, streamExecuteTransactionID)
if err != nil {
t.Fatalf("StreamExecute failed: %v", err)
}
qr, ok := <-stream
if !ok {
t.Fatalf("StreamExecute failed: cannot read result1")
}
if len(qr.Rows) == 0 {
qr.Rows = nil
}
if !reflect.DeepEqual(*qr, streamExecuteQueryResult1) {
t.Errorf("Unexpected result1 from StreamExecute: got %v wanted %v", qr, streamExecuteQueryResult1)
}
qr, ok = <-stream
if !ok {
t.Fatalf("StreamExecute failed: cannot read result2")
}
if len(qr.Fields) == 0 {
qr.Fields = nil
}
if !reflect.DeepEqual(*qr, streamExecuteQueryResult2) {
t.Errorf("Unexpected result2 from StreamExecute: got %v wanted %v", qr, streamExecuteQueryResult2)
}
qr, ok = <-stream
if ok {
t.Fatalf("StreamExecute channel wasn't closed")
}
if err := errFunc(); err != nil {
t.Fatalf("StreamExecute errFunc failed: %v", err)
}
}
开发者ID:payintel,项目名称:vitess,代码行数:35,代码来源:tabletconntest.go
示例14: testStreamExecuteError
func testStreamExecuteError(t *testing.T, conn tabletconn.TabletConn, fake *FakeQueryService) {
ctx := context.Background()
ctx = callerid.NewContext(ctx, testCallerID, testVTGateCallerID)
stream, err := conn.StreamExecute(ctx, streamExecuteQuery, streamExecuteBindVars, streamExecuteTransactionID)
if err != nil {
t.Fatalf("StreamExecute failed: %v", err)
}
qr, err := stream.Recv()
if err != nil {
t.Fatalf("StreamExecute failed: cannot read result1: %v", err)
}
if len(qr.Rows) == 0 {
qr.Rows = nil
}
if !reflect.DeepEqual(*qr, streamExecuteQueryResult1) {
t.Errorf("Unexpected result1 from StreamExecute: got %v wanted %v", qr, streamExecuteQueryResult1)
}
// signal to the server that the first result has been received
close(fake.errorWait)
// After 1 result, we expect to get an error (no more results).
qr, err = stream.Recv()
if err == nil {
t.Fatalf("StreamExecute channel wasn't closed")
}
verifyError(t, err, "StreamExecute")
}
开发者ID:aaijazi,项目名称:vitess,代码行数:26,代码来源:tabletconntest.go
示例15: testBeginPanics
func testBeginPanics(t *testing.T, conn tabletconn.TabletConn, f *FakeQueryService) {
t.Log("testBeginPanics")
testPanicHelper(t, f, "Begin", func(ctx context.Context) error {
_, err := conn.Begin(ctx, TestTarget)
return err
})
}
开发者ID:jmptrader,项目名称:vitess,代码行数:7,代码来源:tabletconntest.go
示例16: testExecutePanics
func testExecutePanics(t *testing.T, conn tabletconn.TabletConn, f *FakeQueryService) {
t.Log("testExecutePanics")
testPanicHelper(t, f, "Execute", func(ctx context.Context) error {
_, err := conn.Execute(ctx, TestTarget, ExecuteQuery, ExecuteBindVars, ExecuteTransactionID)
return err
})
}
开发者ID:jmptrader,项目名称:vitess,代码行数:7,代码来源:tabletconntest.go
示例17: testRollback2Panics
func testRollback2Panics(t *testing.T, conn tabletconn.TabletConn) {
t.Log("testRollback2Panics")
ctx := context.Background()
if err := conn.Rollback2(ctx, rollbackTransactionID); err == nil || !strings.Contains(err.Error(), "caught test panic") {
t.Fatalf("unexpected panic error: %v", err)
}
}
开发者ID:payintel,项目名称:vitess,代码行数:7,代码来源:tabletconntest.go
示例18: testStreamExecute2Error
func testStreamExecute2Error(t *testing.T, conn tabletconn.TabletConn, fake *FakeQueryService) {
t.Log("testStreamExecute2Error")
ctx := context.Background()
stream, errFunc, err := conn.StreamExecute2(ctx, streamExecuteQuery, streamExecuteBindVars, streamExecuteTransactionID)
if err != nil {
t.Fatalf("StreamExecute2 failed: %v", err)
}
qr, ok := <-stream
if !ok {
t.Fatalf("StreamExecute2 failed: cannot read result1")
}
if len(qr.Rows) == 0 {
qr.Rows = nil
}
if !reflect.DeepEqual(*qr, streamExecuteQueryResult1) {
t.Errorf("Unexpected result1 from StreamExecute2: got %v wanted %v", qr, streamExecuteQueryResult1)
}
// signal to the server that the first result has been received
close(fake.errorWait)
// After 1 result, we expect to get an error (no more results).
qr, ok = <-stream
if ok {
t.Fatalf("StreamExecute2 channel wasn't closed")
}
err = errFunc()
verifyError(t, err, "StreamExecute2")
}
开发者ID:payintel,项目名称:vitess,代码行数:27,代码来源:tabletconntest.go
示例19: testExecuteBatch2Panics
func testExecuteBatch2Panics(t *testing.T, conn tabletconn.TabletConn) {
t.Log("testExecuteBatch2Panics")
ctx := context.Background()
if _, err := conn.ExecuteBatch2(ctx, executeBatchQueries, true, executeBatchTransactionID); err == nil || !strings.Contains(err.Error(), "caught test panic") {
t.Fatalf("unexpected panic error: %v", err)
}
}
开发者ID:payintel,项目名称:vitess,代码行数:7,代码来源:tabletconntest.go
示例20: testStreamHealth
func testStreamHealth(t *testing.T, conn tabletconn.TabletConn) {
t.Log("testStreamHealth")
streamHealthSynchronization = make(chan struct{})
ctx := context.Background()
c, errFunc, err := conn.StreamHealth(ctx)
if err != nil {
t.Fatalf("StreamHealth failed: %v", err)
}
// channel should have one response, then closed
shr, ok := <-c
if !ok {
t.Fatalf("StreamHealth got no response")
}
if !reflect.DeepEqual(*shr, *testStreamHealthStreamHealthResponse) {
t.Errorf("invalid StreamHealthResponse: got %v expected %v", *shr, *testStreamHealthStreamHealthResponse)
}
// close streamHealthSynchronization so server side knows we
// got the response, and it can send the error
close(streamHealthSynchronization)
_, ok = <-c
if ok {
t.Fatalf("StreamHealth wasn't closed")
}
err = errFunc()
if !strings.Contains(err.Error(), testStreamHealthError) {
t.Fatalf("StreamHealth failed with the wrong error: %v", err)
}
}
开发者ID:payintel,项目名称:vitess,代码行数:32,代码来源:tabletconntest.go
注:本文中的github.com/youtube/vitess/go/vt/tabletserver/tabletconn.TabletConn类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论