[ 
https://issues.apache.org/jira/browse/SCB-657?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16522170#comment-16522170
 ] 

ASF GitHub Bot commented on SCB-657:
------------------------------------

little-cui closed pull request #368: SCB-657  Configurable timeout of request 
etcd
URL: https://github.com/apache/incubator-servicecomb-service-center/pull/368
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/etc/conf/app.conf b/etc/conf/app.conf
index df25c30f..5a2b8089 100644
--- a/etc/conf/app.conf
+++ b/etc/conf/app.conf
@@ -64,6 +64,8 @@ manager_cluster = "127.0.0.1:2379"
 #<=0, use default 30s
 auto_sync_interval = 30s
 
+registry_timeout = 30s
+
 # indicate how many revision you want to keep in etcd
 compact_index_delta = 100
 compact_interval = 12h
diff --git a/server/infra/registry/registry.go 
b/server/infra/registry/registry.go
index b986723a..885a6549 100644
--- a/server/infra/registry/registry.go
+++ b/server/infra/registry/registry.go
@@ -24,12 +24,20 @@ import (
        "golang.org/x/net/context"
        "strconv"
        "time"
+       "github.com/apache/incubator-servicecomb-service-center/pkg/util"
 )
 
 var defaultRegistryConfig Config
 
 func init() {
        defaultRegistryConfig.ClusterAddresses = 
beego.AppConfig.DefaultString("manager_cluster", "sc-0=http://127.0.0.1:2380";)
+       requestTimeConfig := beego.AppConfig.DefaultString("registry_timeout", 
"30s")
+       var err error
+       defaultRegistryConfig.RequestTimeOut, err = 
time.ParseDuration(requestTimeConfig)
+       if err != nil {
+           util.Logger().Errorf(err, "registry_timeout is invaild, use default 
time 30s")
+           defaultRegistryConfig.RequestTimeOut, _ = time.ParseDuration("30s")
+       }
 }
 
 type ActionType int
@@ -144,7 +152,6 @@ const (
 )
 
 const (
-       REQUEST_TIMEOUT    = 30 * time.Second
        DEFAULT_PAGE_COUNT = 4096 // grpc does not allow to transport a large 
body more then 4MB in a request.
 )
 
@@ -171,6 +178,7 @@ type Registry interface {
 type Config struct {
        EmbedMode        string
        ClusterAddresses string
+       RequestTimeOut   time.Duration
 }
 
 type PluginOp struct {
@@ -367,7 +375,7 @@ func OpCmp(opt CompareOperation, result CompareResult, v 
interface{}) (cmp Compa
 }
 
 func WithTimeout(ctx context.Context) (context.Context, context.CancelFunc) {
-       return context.WithTimeout(ctx, REQUEST_TIMEOUT)
+       return context.WithTimeout(ctx, defaultRegistryConfig.RequestTimeOut)
 }
 
 func RegistryConfig() *Config {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Configurable timeout of request etcd
> ------------------------------------
>
>                 Key: SCB-657
>                 URL: https://issues.apache.org/jira/browse/SCB-657
>             Project: Apache ServiceComb
>          Issue Type: New Feature
>          Components: Service-Center
>            Reporter: little-cui
>            Assignee: little-cui
>            Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to