当前位置: 首页>>代码示例>>Golang>>正文


Golang VTGateConn.StreamExecuteShard方法代码示例

本文整理汇总了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)
}
开发者ID:pranjal5215,项目名称:vitess,代码行数:10,代码来源:client.go

示例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)
	}
}
开发者ID:pranjal5215,项目名称:vitess,代码行数:45,代码来源:client.go


注:本文中的github.com/youtube/vitess/go/vt/vtgate/vtgateconn.VTGateConn.StreamExecuteShard方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。