From 988c93472001a686b41fc25647125d342ad055a3 Mon Sep 17 00:00:00 2001 From: Menghan Li Date: Thu, 28 Apr 2016 14:42:16 -0700 Subject: [PATCH] Rename genericServer to byteBufServer --- benchmark/benchmark.go | 16 ++++++++-------- benchmark/worker/benchmark_client.go | 2 +- benchmark/worker/benchmark_server.go | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/benchmark/benchmark.go b/benchmark/benchmark.go index 5bb87ea0..574c4a92 100644 --- a/benchmark/benchmark.go +++ b/benchmark/benchmark.go @@ -107,16 +107,16 @@ func StartServer(addr string, opts ...grpc.ServerOption) (string, func()) { } } -type genericTestServer struct { +type byteBufServer struct { reqSize int32 respSize int32 } -func (s *genericTestServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) { +func (s *byteBufServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) { return &testpb.SimpleResponse{}, nil } -func (s *genericTestServer) StreamingCall(stream testpb.BenchmarkService_StreamingCallServer) error { +func (s *byteBufServer) StreamingCall(stream testpb.BenchmarkService_StreamingCallServer) error { for { m := make([]byte, s.reqSize) err := stream.(grpc.ServerStream).RecvMsg(m) @@ -132,15 +132,15 @@ func (s *genericTestServer) StreamingCall(stream testpb.BenchmarkService_Streami } } -// StartGenericServer starts a benchmark service server that supports custom codec. +// StartbyteBufServer starts a benchmark service server that supports custom codec. // It returns its listen address and a function to stop the server. -func StartGenericServer(addr string, reqSize, respSize int32, opts ...grpc.ServerOption) (string, func()) { +func StartByteBufServer(addr string, reqSize, respSize int32, opts ...grpc.ServerOption) (string, func()) { lis, err := net.Listen("tcp", addr) if err != nil { grpclog.Fatalf("Failed to listen: %v", err) } s := grpc.NewServer(opts...) - testpb.RegisterBenchmarkServiceServer(s, &genericTestServer{reqSize: reqSize, respSize: respSize}) + testpb.RegisterBenchmarkServiceServer(s, &byteBufServer{reqSize: reqSize, respSize: respSize}) go s.Serve(lis) return lis.Addr().String(), func() { s.Stop() @@ -178,8 +178,8 @@ func DoStreamingRoundTrip(stream testpb.BenchmarkService_StreamingCallClient, re return nil } -// DoGenericStreamingRoundTrip performs a round trip for a single streaming rpc, using custom codec. -func DoGenericStreamingRoundTrip(stream testpb.BenchmarkService_StreamingCallClient, reqSize, respSize int) error { +// DoByteBufStreamingRoundTrip performs a round trip for a single streaming rpc, using custom codec. +func DoByteBufStreamingRoundTrip(stream testpb.BenchmarkService_StreamingCallClient, reqSize, respSize int) error { if err := stream.(grpc.ClientStream).SendMsg(make([]byte, reqSize)); err != nil { return grpc.Errorf(grpc.Code(err), "StreamingCall(_).(ClientStream).SendMsg: %v", grpc.ErrorDesc(err)) } diff --git a/benchmark/worker/benchmark_client.go b/benchmark/worker/benchmark_client.go index 703ddd5d..a5b1dce5 100644 --- a/benchmark/worker/benchmark_client.go +++ b/benchmark/worker/benchmark_client.go @@ -237,7 +237,7 @@ func (bc *benchmarkClient) doCloseLoopUnaryBenchmark(conns []*grpc.ClientConn, r func (bc *benchmarkClient) doCloseLoopStreamingBenchmark(conns []*grpc.ClientConn, rpcCountPerConn int, reqSize int, respSize int, payloadType string) { var doRPC func(testpb.BenchmarkService_StreamingCallClient, int, int) error if payloadType == "bytebuf" { - doRPC = benchmark.DoGenericStreamingRoundTrip + doRPC = benchmark.DoByteBufStreamingRoundTrip } else { doRPC = benchmark.DoStreamingRoundTrip } diff --git a/benchmark/worker/benchmark_server.go b/benchmark/worker/benchmark_server.go index f6b91412..1b58a854 100644 --- a/benchmark/worker/benchmark_server.go +++ b/benchmark/worker/benchmark_server.go @@ -114,7 +114,7 @@ func startBenchmarkServerWithSetup(setup *testpb.ServerConfig, serverPort int) ( switch payload := setup.PayloadConfig.Payload.(type) { case *testpb.PayloadConfig_BytebufParams: opts = append(opts, grpc.CustomCodec(byteBufCodec{})) - addr, close = benchmark.StartGenericServer(":"+strconv.Itoa(port), payload.BytebufParams.ReqSize, payload.BytebufParams.RespSize, opts...) + addr, close = benchmark.StartByteBufServer(":"+strconv.Itoa(port), payload.BytebufParams.ReqSize, payload.BytebufParams.RespSize, opts...) case *testpb.PayloadConfig_SimpleParams: addr, close = benchmark.StartServer(":"+strconv.Itoa(port), opts...) case *testpb.PayloadConfig_ComplexParams: