Skip to content

Commit da37931

Browse files
committed
grpc: add grpc msg size config and set default to 64m
fix #96
1 parent b0c85a6 commit da37931

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

cmd/go-judge/config/config.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@ type Config struct {
3838
FileTimeout time.Duration `flagUsage:"specified timeout for filestore files"`
3939

4040
// server config
41-
HTTPAddr string `flagUsage:"specifies the http binding address"`
42-
EnableGRPC bool `flagUsage:"enable gRPC endpoint"`
43-
GRPCAddr string `flagUsage:"specifies the grpc binding address"`
44-
MonitorAddr string `flagUsage:"specifies the metrics binding address"`
45-
AuthToken string `flagUsage:"bearer token auth for REST / gRPC"`
46-
EnableDebug bool `flagUsage:"enable debug endpoint"`
47-
EnableMetrics bool `flagUsage:"enable prometheus metrics endpoint"`
41+
HTTPAddr string `flagUsage:"specifies the http binding address"`
42+
EnableGRPC bool `flagUsage:"enable gRPC endpoint"`
43+
GRPCAddr string `flagUsage:"specifies the grpc binding address"`
44+
MonitorAddr string `flagUsage:"specifies the metrics binding address"`
45+
AuthToken string `flagUsage:"bearer token auth for REST / gRPC"`
46+
GRPCMsgSize *envexec.Size `flagUsage:"message size limit for gRPC message" default:"64m"`
47+
EnableDebug bool `flagUsage:"enable debug endpoint"`
48+
EnableMetrics bool `flagUsage:"enable prometheus metrics endpoint"`
4849

4950
// logger config
5051
Release bool `flagUsage:"release level of logs"`

cmd/go-judge/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ func newGRPCServer(conf *config.Config, esServer pb.ExecutorServer) *grpc.Server
365365
grpcServer := grpc.NewServer(
366366
grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(streamMiddleware...)),
367367
grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(unaryMiddleware...)),
368+
grpc.MaxRecvMsgSize(int(conf.GRPCMsgSize.Byte())),
368369
)
369370
pb.RegisterExecutorServer(grpcServer, esServer)
370371
grpc_prometheus.Register(grpcServer)

0 commit comments

Comments
 (0)