Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing to set the number of stream workers #4

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ type Config struct {
GPRCServerMaxRecvMsgSize int `yaml:"grpc_server_max_recv_msg_size"`
GRPCServerMaxSendMsgSize int `yaml:"grpc_server_max_send_msg_size"`
GPRCServerMaxConcurrentStreams uint `yaml:"grpc_server_max_concurrent_streams"`
GPRCServerNumStreamWorkers uint `yaml:"grpc_server_num_stream_workers"`
GRPCServerMaxConnectionIdle time.Duration `yaml:"grpc_server_max_connection_idle"`
GRPCServerMaxConnectionAge time.Duration `yaml:"grpc_server_max_connection_age"`
GRPCServerMaxConnectionAgeGrace time.Duration `yaml:"grpc_server_max_connection_age_grace"`
Expand Down Expand Up @@ -159,6 +160,7 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
f.IntVar(&cfg.GPRCServerMaxRecvMsgSize, "server.grpc-max-recv-msg-size-bytes", 4*1024*1024, "Limit on the size of a gRPC message this server can receive (bytes).")
f.IntVar(&cfg.GRPCServerMaxSendMsgSize, "server.grpc-max-send-msg-size-bytes", 4*1024*1024, "Limit on the size of a gRPC message this server can send (bytes).")
f.UintVar(&cfg.GPRCServerMaxConcurrentStreams, "server.grpc-max-concurrent-streams", 100, "Limit on the number of concurrent streams for gRPC calls (0 = unlimited)")
f.UintVar(&cfg.GPRCServerNumStreamWorkers, "server.grpc_server-num-stream-workers", 0, "Number of worker goroutines that should be used to process incoming streams.Setting this 0 (default) will disable workers and spawn a new goroutine for each stream.")
f.DurationVar(&cfg.GRPCServerMaxConnectionIdle, "server.grpc.keepalive.max-connection-idle", infinty, "The duration after which an idle connection should be closed. Default: infinity")
f.DurationVar(&cfg.GRPCServerMaxConnectionAge, "server.grpc.keepalive.max-connection-age", infinty, "The duration for the maximum amount of time a connection may exist before it will be closed. Default: infinity")
f.DurationVar(&cfg.GRPCServerMaxConnectionAgeGrace, "server.grpc.keepalive.max-connection-age-grace", infinty, "An additive period after max-connection-age after which the connection will be forcibly closed. Default: infinity")
Expand Down Expand Up @@ -354,6 +356,7 @@ func newServer(cfg Config, metrics *Metrics) (*Server, error) {
grpcOptions := []grpc.ServerOption{
grpc.ChainUnaryInterceptor(grpcMiddleware...),
grpc.ChainStreamInterceptor(grpcStreamMiddleware...),
grpc.NumStreamWorkers(uint32(cfg.GPRCServerNumStreamWorkers)),
grpc.KeepaliveParams(grpcKeepAliveOptions),
grpc.KeepaliveEnforcementPolicy(grpcKeepAliveEnforcementPolicy),
grpc.MaxRecvMsgSize(cfg.GPRCServerMaxRecvMsgSize),
Expand Down