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


Golang TabletConn.UpdateStream方法代码示例

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

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

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


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