本文整理汇总了Golang中github.com/youtube/vitess/go/vt/proto/queryservice.RegisterQueryServer函数的典型用法代码示例。如果您正苦于以下问题:Golang RegisterQueryServer函数的具体用法?Golang RegisterQueryServer怎么用?Golang RegisterQueryServer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RegisterQueryServer函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestGoRPCTabletConn
// This test makes sure the go rpc service works
func TestGoRPCTabletConn(t *testing.T) {
// fake service
service := tabletconntest.CreateFakeServer(t)
// listen on a random port
listener, err := net.Listen("tcp", ":0")
if err != nil {
t.Fatalf("Cannot listen: %v", err)
}
port := listener.Addr().(*net.TCPAddr).Port
// Create a gRPC server and listen on the port
server := grpc.NewServer()
pbs.RegisterQueryServer(server, grpcqueryservice.New(service))
go server.Serve(listener)
// Create a gRPC client connecting to the server
ctx := context.Background()
client, err := DialTablet(ctx, topo.EndPoint{
Host: "localhost",
NamedPortMap: map[string]int{
"grpc": port,
},
}, tabletconntest.TestKeyspace, tabletconntest.TestShard, 30*time.Second)
if err != nil {
t.Fatalf("dial failed: %v", err)
}
// run the test suite
tabletconntest.TestSuite(t, client, service)
// and clean up
client.Close()
}
示例2: init
func init() {
tabletserver.RegisterFunctions = append(tabletserver.RegisterFunctions, func(qsc tabletserver.Controller) {
if servenv.GRPCCheckServiceMap("queryservice") {
queryservicepb.RegisterQueryServer(servenv.GRPCServer, &query{qsc.QueryService()})
}
})
}
示例3: init
func init() {
tabletserver.QueryServiceControlRegisterFunctions = append(tabletserver.QueryServiceControlRegisterFunctions, func(qsc tabletserver.QueryServiceControl) {
if servenv.GRPCCheckServiceMap("queryservice") {
pbs.RegisterQueryServer(servenv.GRPCServer, New(qsc.QueryService()))
}
})
}
示例4: RegisterForTest
// RegisterForTest should only be used by unit tests
func RegisterForTest(s *grpc.Server, server queryservice.QueryService) {
queryservicepb.RegisterQueryServer(s, &query{server})
}