@@ -13,6 +13,7 @@ import (
13
13
grpcprometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
14
14
"github.com/grpc-ecosystem/grpc-gateway/runtime"
15
15
log "github.com/sirupsen/logrus"
16
+ "github.com/stackrox/scanner/pkg/env"
16
17
"github.com/stackrox/scanner/pkg/mtls"
17
18
"google.golang.org/grpc"
18
19
"google.golang.org/grpc/credentials/insecure"
@@ -26,6 +27,14 @@ func init() {
26
27
grpcprometheus .EnableHandlingTimeHistogram ()
27
28
}
28
29
30
+ func maxGrpcConcurrentStreams () uint32 {
31
+ if env .MaxGrpcConcurrentStreams .Int () <= 0 {
32
+ return env .DefaultMaxGrpcConcurrentStreams
33
+ }
34
+
35
+ return uint32 (env .MaxGrpcConcurrentStreams .Int ())
36
+ }
37
+
29
38
// NewAPI creates a new gRPC API instantiation
30
39
func NewAPI (opts ... ConfigOpts ) API {
31
40
var config Config
@@ -60,7 +69,10 @@ func (a *apiImpl) connectToLocalEndpoint() (*grpc.ClientConn, error) {
60
69
}
61
70
62
71
func (a * apiImpl ) Start () {
63
- grpcServer := grpc .NewServer (grpc .ChainUnaryInterceptor (a .config .UnaryInterceptors ... ))
72
+ grpcServer := grpc .NewServer (
73
+ grpc .ChainUnaryInterceptor (a .config .UnaryInterceptors ... ),
74
+ grpc .MaxConcurrentStreams (maxGrpcConcurrentStreams ()),
75
+ )
64
76
for _ , serv := range a .apiServices {
65
77
serv .RegisterServiceServer (grpcServer )
66
78
}
0 commit comments