From ecbc34aacae0c9034de85c044cfcc9600b85cc50 Mon Sep 17 00:00:00 2001 From: Yuxuan Li Date: Wed, 26 Apr 2017 17:39:57 -0700 Subject: [PATCH] move server defaults, delete defer cancel() in stream.go --- rpc_util.go | 22 +++++++++++----------- server.go | 5 +++++ stream.go | 2 -- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/rpc_util.go b/rpc_util.go index 36af31f8d..35f6dbf33 100644 --- a/rpc_util.go +++ b/rpc_util.go @@ -483,17 +483,6 @@ type ServiceConfig struct { Methods map[string]MethodConfig } -// SupportPackageIsVersion4 is referenced from generated protocol buffer files -// to assert that that code is compatible with this version of the grpc package. -// -// This constant may be renamed in the future if a change in the generated code -// requires a synchronised update of grpc-go and protoc-gen-go. This constant -// should not be referenced from any other code. -const SupportPackageIsVersion4 = true - -// Version is the current grpc version. -const Version = "1.3.0-dev" - func min(a, b *int) *int { if *a < *b { return a @@ -514,4 +503,15 @@ func getMaxSize(mcMax, doptMax *int, defaultVal int) *int { return doptMax } +// SupportPackageIsVersion4 is referenced from generated protocol buffer files +// to assert that that code is compatible with this version of the grpc package. +// +// This constant may be renamed in the future if a change in the generated code +// requires a synchronised update of grpc-go and protoc-gen-go. This constant +// should not be referenced from any other code. +const SupportPackageIsVersion4 = true + +// Version is the current grpc version. +const Version = "1.3.0-dev" + const grpcUA = "grpc-go/" + Version diff --git a/server.go b/server.go index e4433cf39..3c8bd69c6 100644 --- a/server.go +++ b/server.go @@ -61,6 +61,11 @@ import ( "google.golang.org/grpc/transport" ) +const ( + defaultServerMaxReceiveMessageSize = 1024 * 1024 * 4 + defaultServerMaxSendMessageSize = 1024 * 1024 * 4 +) + type methodHandler func(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor UnaryServerInterceptor) (interface{}, error) // MethodDesc represents an RPC service's method specification. diff --git a/stream.go b/stream.go index 8dcd0627a..ee68bbf56 100644 --- a/stream.go +++ b/stream.go @@ -119,9 +119,7 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth } if mc.Timeout != nil && *mc.Timeout >= 0 { - var cancel context.CancelFunc ctx, cancel = context.WithTimeout(ctx, *mc.Timeout) - defer cancel() } opts = append(cc.dopts.callOptions, opts...)