This is an automated email from the ASF dual-hosted git repository.

littlecui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git


The following commit(s) were added to refs/heads/master by this push:
     new ff89865  SCB-1059 Add grpc keepalive time (#537)
ff89865 is described below

commit ff89865a5fb6112b4d00952dc8f2180696ad6660
Author: little-cui <sure_0...@qq.com>
AuthorDate: Tue Mar 19 11:27:14 2019 +0800

    SCB-1059 Add grpc keepalive time (#537)
---
 pkg/rest/client.go                        |  1 +
 server/plugin/pkg/registry/etcd/common.go |  6 ++++++
 server/plugin/pkg/registry/etcd/etcd.go   | 10 ++++++----
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/pkg/rest/client.go b/pkg/rest/client.go
index 6eb5843..c0ea997 100644
--- a/pkg/rest/client.go
+++ b/pkg/rest/client.go
@@ -148,6 +148,7 @@ func DumpRequestOut(req *http.Request) {
                return
        }
 
+       fmt.Println(">", req.URL.String())
        b, _ := httputil.DumpRequestOut(req, true)
        buffer.ReadLine(bytes.NewBuffer(b), func(line string) bool {
                fmt.Println(">", line)
diff --git a/server/plugin/pkg/registry/etcd/common.go 
b/server/plugin/pkg/registry/etcd/common.go
index 6e4a1d0..8191a7c 100644
--- a/server/plugin/pkg/registry/etcd/common.go
+++ b/server/plugin/pkg/registry/etcd/common.go
@@ -26,6 +26,12 @@ const (
        healthCheckTimeout    = 5 * time.Second
        healthCheckRetryTimes = 3
 
+       // see google.golang.org/grpc/keepalive/keepalive.go
+       // after a duration of this time if the client doesn't see any activity
+       // it pings the server to see if the transport is still alive.
+       keepAliveTime    = 2 * time.Second
+       keepAliveTimeout = 5 * time.Second
+
        // see github.com/coreos/etcd/clientv3/options.go
        // maxSendMsgSize = 2MB
        maxRecvMsgSize = math.MaxInt32
diff --git a/server/plugin/pkg/registry/etcd/etcd.go 
b/server/plugin/pkg/registry/etcd/etcd.go
index 7af3300..2f872ca 100644
--- a/server/plugin/pkg/registry/etcd/etcd.go
+++ b/server/plugin/pkg/registry/etcd/etcd.go
@@ -101,10 +101,12 @@ func (c *EtcdClient) Initialize() (err error) {
 
 func (c *EtcdClient) newClient() (*clientv3.Client, error) {
        client, err := clientv3.New(clientv3.Config{
-               Endpoints:          c.Endpoints,
-               DialTimeout:        c.DialTimeout,
-               TLS:                c.TLSConfig,
-               MaxCallRecvMsgSize: maxRecvMsgSize,
+               Endpoints:            c.Endpoints,
+               DialTimeout:          c.DialTimeout,
+               TLS:                  c.TLSConfig,
+               MaxCallRecvMsgSize:   maxRecvMsgSize,
+               DialKeepAliveTime:    keepAliveTime,
+               DialKeepAliveTimeout: keepAliveTimeout,
        })
        defer func() {
                if err != nil {

Reply via email to