You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2018/06/25 11:27:30 UTC
[incubator-servicecomb-service-center] branch master updated:
SCB-657 Configurable timeout of request etcd (#368)
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/incubator-servicecomb-service-center.git
The following commit(s) were added to refs/heads/master by this push:
new 3c578f0 SCB-657 Configurable timeout of request etcd (#368)
3c578f0 is described below
commit 3c578f0877d544908ed6c91ceeed703f3b0e6f47
Author: mt-monster <me...@huawei.com>
AuthorDate: Mon Jun 25 19:27:28 2018 +0800
SCB-657 Configurable timeout of request etcd (#368)
* Modify connection etcd timeout configurable
* Modify connection etcd timeout configurable
* Update registry.go
---
etc/conf/app.conf | 2 ++
server/infra/registry/registry.go | 12 ++++++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/etc/conf/app.conf b/etc/conf/app.conf
index 22f98b0..02bd021 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 b986723..885a654 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 {