This is an automated email from the ASF dual-hosted git repository.
aaronai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git
The following commit(s) were added to refs/heads/master by this push:
new ae289eaf Go: Disable keep alive for gRPC channel (#481)
ae289eaf is described below
commit ae289eaf8b5b8481a59f310b4d97faa75e5bdb18
Author: racoon <[email protected]>
AuthorDate: Tue Apr 18 12:46:44 2023 +0800
Go: Disable keep alive for gRPC channel (#481)
*Go: Disable keep alive for gRPC channel
---
golang/conn.go | 8 --------
golang/conn_options.go | 38 --------------------------------------
2 files changed, 46 deletions(-)
diff --git a/golang/conn.go b/golang/conn.go
index 75b30b62..7b52e02b 100644
--- a/golang/conn.go
+++ b/golang/conn.go
@@ -26,7 +26,6 @@ import (
validator "github.com/go-playground/validator/v10"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
- "google.golang.org/grpc/keepalive"
)
var (
@@ -107,13 +106,6 @@ func (c *clientConn) Close() error {
}
func (c *clientConn) dialSetupOpts(dopts ...grpc.DialOption) (opts
[]grpc.DialOption, err error) {
- if c.opts.DialKeepAliveTime > 0 {
- opts = append(opts,
grpc.WithKeepaliveParams(keepalive.ClientParameters{
- Time: c.opts.DialKeepAliveTime,
- Timeout: c.opts.DialKeepAliveTimeout,
- PermitWithoutStream: c.opts.PermitWithoutStream,
- }))
- }
opts = append(opts, dopts...)
if c.creds != nil {
opts = append(opts, grpc.WithTransportCredentials(c.creds))
diff --git a/golang/conn_options.go b/golang/conn_options.go
index 2f59432d..a3ec09d9 100644
--- a/golang/conn_options.go
+++ b/golang/conn_options.go
@@ -53,17 +53,6 @@ type connOptions struct {
// other operations that do not have an explicit context.
Context context.Context
- // DialKeepAliveTime is the time after which client pings the server to
see if
- // transport is alive.
- DialKeepAliveTime time.Duration
-
- // DialKeepAliveTimeout is the time that the client waits for a
response for the
- // keep-alive probe. If the response is not received in this time, the
connection is closed.
- DialKeepAliveTimeout time.Duration
-
- // PermitWithoutStream when set will allow client to send keepalive
pings to server without any active streams(RPCs).
- PermitWithoutStream bool
-
// DialTimeout is the timeout for failing to establish a connection.
DialTimeout time.Duration
@@ -79,7 +68,6 @@ var defaultConnOptions = connOptions{
RootCAs: x509.NewCertPool(),
InsecureSkipVerify: true,
},
- DialKeepAliveTime: time.Second * 30,
Logger: zaplog.New(),
}
@@ -157,32 +145,6 @@ func WithContext(ctx context.Context) ConnOption {
})
}
-// WithDialKeepAliveTime returns a ConnOption that sets DialKeepAliveTime for
grpc.DialContext.
-// DialKeepAliveTime is the time after which client pings the server to see if
transport is alive.
-func WithDialKeepAliveTime(d time.Duration) ConnOption {
- return newFuncConnOption(func(o *connOptions) {
- o.DialKeepAliveTime = d
- })
-}
-
-// WithDialKeepAliveTimeout returns a ConnOption that sets
DialKeepAliveTimeout for grpc.DialContext.
-// DialKeepAliveTimeout is the time that the client waits for a response for
the keep-alive probe.
-// If the response is not received in this time, the connection is closed.
-func WithDialKeepAliveTimeout(d time.Duration) ConnOption {
- return newFuncConnOption(func(o *connOptions) {
- o.DialKeepAliveTimeout = d
- })
-}
-
-// WithPermitWithoutStream returns a ConnOption that sets PermitWithoutStream
for grpc.DialContext.
-// PermitWithoutStream when set will allow client to send keepalive pings to
server without any
-// active streams(RPCs).
-func WithPermitWithoutStream(permit bool) ConnOption {
- return newFuncConnOption(func(o *connOptions) {
- o.PermitWithoutStream = permit
- })
-}
-
func WithZapLogger(logger *zap.Logger) ConnOption {
return newFuncConnOption(func(o *connOptions) {
o.Logger = logger