server/grpc: add MaxConn option to limit max inflight requests (#1247)

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2020-02-24 16:48:56 +03:00
parent 28ef20ef4a
commit f727b75b6f
2 changed files with 20 additions and 6 deletions

View File

@@ -18,6 +18,7 @@ type codecsKey struct{}
type grpcOptions struct{}
type netListener struct{}
type maxMsgSizeKey struct{}
type maxConnKey struct{}
type tlsAuth struct{}
// gRPC Codec to be used to encode/decode requests for a given content type
@@ -40,6 +41,11 @@ func AuthTLS(t *tls.Config) server.Option {
return setServerOption(tlsAuth{}, t)
}
// MaxConn specifies maximum number of max simultaneous connections to server
func MaxConn(n int) server.Option {
return setServerOption(maxConnKey{}, n)
}
// Listener specifies the net.Listener to use instead of the default
func Listener(l net.Listener) server.Option {
return setServerOption(netListener{}, l)