StartServer starts a gRPC server serving a benchmark service according to info. It returns a function to stop the server.
(info ServerInfo, opts ...grpc.ServerOption)
| 257 | // StartServer starts a gRPC server serving a benchmark service according to info. |
| 258 | // It returns a function to stop the server. |
| 259 | func StartServer(info ServerInfo, opts ...grpc.ServerOption) func() { |
| 260 | s := grpc.NewServer(opts...) |
| 261 | switch info.Type { |
| 262 | case "protobuf": |
| 263 | testgrpc.RegisterBenchmarkServiceServer(s, &testServer{}) |
| 264 | case "bytebuf": |
| 265 | respSize, ok := info.Metadata.(int32) |
| 266 | if !ok { |
| 267 | logger.Fatalf("failed to StartServer, invalid metadata: %v, for Type: %v", info.Metadata, info.Type) |
| 268 | } |
| 269 | testgrpc.RegisterBenchmarkServiceServer(s, &byteBufServer{respSize: respSize}) |
| 270 | default: |
| 271 | logger.Fatalf("failed to StartServer, unknown Type: %v", info.Type) |
| 272 | } |
| 273 | go s.Serve(info.Listener) |
| 274 | return func() { |
| 275 | s.Stop() |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | // DoUnaryCall performs a unary RPC with given stub and request and response sizes. |
| 280 | func DoUnaryCall(tc testgrpc.BenchmarkServiceClient, reqSize, respSize int) error { |
no test coverage detected