You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by xi...@apache.org on 2021/06/22 14:25:47 UTC
[dubbo-go-pixiu] branch develop updated: move timeout config
outside the clusters (#190)
This is an automated email from the ASF dual-hosted git repository.
xiaoliu pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go-pixiu.git
The following commit(s) were added to refs/heads/develop by this push:
new 73949d3 move timeout config outside the clusters (#190)
73949d3 is described below
commit 73949d394041c1b9e45378bf3690ced64055adf2
Author: alchemy-lee <27...@qq.com>
AuthorDate: Tue Jun 22 22:25:39 2021 +0800
move timeout config outside the clusters (#190)
---
configs/conf.yaml | 5 +++--
pkg/client/dubbo/dubbo.go | 11 +++++++----
pkg/config/conf_test.yaml | 5 +++--
pkg/config/config_load_test.go | 14 ++++++++------
pkg/model/bootstrap.go | 7 +++++++
pkg/model/cluster.go | 20 +++++++++-----------
samples/admin/proxy/conf.yaml | 5 +++--
samples/dubbogo/http/pixiu/conf.yaml | 5 +++--
samples/dubbogo/multi/config/conf.yaml | 5 +++--
samples/dubbogo/simple/body/conf.yaml | 5 +++--
samples/dubbogo/simple/mix/conf.yaml | 5 +++--
samples/dubbogo/simple/proxy/conf.yaml | 5 +++--
samples/dubbogo/simple/query/conf.yaml | 5 +++--
samples/dubbogo/simple/uri/conf.yaml | 5 +++--
samples/plugins/config/conf.yaml | 5 +++--
15 files changed, 64 insertions(+), 43 deletions(-)
diff --git a/configs/conf.yaml b/configs/conf.yaml
index 3ef86e8..0bd99f2 100644
--- a/configs/conf.yaml
+++ b/configs/conf.yaml
@@ -75,8 +75,6 @@ static_resources:
clusters:
- name: "test_dubbo"
lb_policy: "RoundRobin"
- connect_timeout: "5s"
- request_timeout: "10s"
registries:
"zookeeper":
protocol: "zookeeper"
@@ -84,6 +82,9 @@ static_resources:
address: "127.0.0.1:2181"
username: ""
password: ""
+ timeout_config:
+ connect_timeout: "5s"
+ request_timeout: "10s"
shutdown_config:
timeout: "60s"
step_timeout: "10s"
diff --git a/pkg/client/dubbo/dubbo.go b/pkg/client/dubbo/dubbo.go
index 0c828eb..9e5454e 100644
--- a/pkg/client/dubbo/dubbo.go
+++ b/pkg/client/dubbo/dubbo.go
@@ -89,18 +89,21 @@ func NewDubboClient() *Client {
// Init init dubbo, config mapping can do here
func (dc *Client) Init() error {
- cls := config.GetBootstrap().StaticResources.Clusters
+ staticResources := config.GetBootstrap().StaticResources
+ cls := staticResources.Clusters
+ tc := staticResources.TimeoutConfig
- // dubbogo comsumer config
+ // dubbogo consumer config
dgCfg = dg.ConsumerConfig{
Check: new(bool),
Registries: make(map[string]*dg.RegistryConfig, 4),
}
+ // timeout config
+ dgCfg.Connect_Timeout = tc.ConnectTimeoutStr
+ dgCfg.Request_Timeout = tc.RequestTimeoutStr
dgCfg.ApplicationConfig = defaultApplication
for i := range cls {
c := cls[i]
- dgCfg.Request_Timeout = c.RequestTimeoutStr
- dgCfg.Connect_Timeout = c.ConnectTimeoutStr
for k, v := range c.Registries {
if len(v.Protocol) == 0 {
logger.Warnf("can not find registry protocol config, use default type 'zookeeper'")
diff --git a/pkg/config/conf_test.yaml b/pkg/config/conf_test.yaml
index c79be62..889a922 100644
--- a/pkg/config/conf_test.yaml
+++ b/pkg/config/conf_test.yaml
@@ -63,8 +63,6 @@ static_resources:
clusters:
- name: "test_dubbo"
lb_policy: "RoundRobin"
- connect_timeout: "5s"
- request_timeout: "10s"
registries:
"zookeeper":
timeout: "3s"
@@ -74,6 +72,9 @@ static_resources:
"consul":
timeout: "3s"
address: "127.0.0.1:8500"
+ timeout_config:
+ connect_timeout: "5s"
+ request_timeout: "10s"
shutdown_config:
timeout: "60s"
step_timeout: "10s"
diff --git a/pkg/config/config_load_test.go b/pkg/config/config_load_test.go
index 375ef92..d589cd5 100644
--- a/pkg/config/config_load_test.go
+++ b/pkg/config/config_load_test.go
@@ -114,12 +114,10 @@ func TestMain(m *testing.M) {
},
Clusters: []*model.Cluster{
{
- Name: "test_dubbo",
- TypeStr: "EDS",
- Type: model.EDS,
- LbStr: "RoundRobin",
- ConnectTimeoutStr: "5s",
- RequestTimeoutStr: "10s",
+ Name: "test_dubbo",
+ TypeStr: "EDS",
+ Type: model.EDS,
+ LbStr: "RoundRobin",
Registries: map[string]model.Registry{
"zookeeper": {
Timeout: "3s",
@@ -134,6 +132,10 @@ func TestMain(m *testing.M) {
},
},
},
+ TimeoutConfig: model.TimeoutConfig{
+ ConnectTimeoutStr: "5s",
+ RequestTimeoutStr: "10s",
+ },
ShutdownConfig: &model.ShutdownConfig{
Timeout: "60s",
StepTimeout: "10s",
diff --git a/pkg/model/bootstrap.go b/pkg/model/bootstrap.go
index 1c99c3d..c5d491f 100644
--- a/pkg/model/bootstrap.go
+++ b/pkg/model/bootstrap.go
@@ -56,6 +56,7 @@ func (bs *Bootstrap) ExistCluster(name string) bool {
type StaticResources struct {
Listeners []Listener `yaml:"listeners" json:"listeners" mapstructure:"listeners"`
Clusters []*Cluster `yaml:"clusters" json:"clusters" mapstructure:"clusters"`
+ TimeoutConfig TimeoutConfig `yaml:"timeout_config" json:"timeout_config" mapstructure:"timeout_config"`
ShutdownConfig *ShutdownConfig `yaml:"shutdown_config" json:"shutdown_config" mapstructure:"shutdown_config"`
PprofConf PprofConf `yaml:"pprofConf" json:"pprofConf" mapstructure:"pprofConf"`
AccessLogConfig AccessLogConfig `yaml:"accessLog" json:"accessLog" mapstructure:"accessLog"`
@@ -77,3 +78,9 @@ type APIMetaConfig struct {
Address string `yaml:"address" json:"address,omitempty"`
APIConfigPath string `default:"/pixiu/config/api" yaml:"api_config_path" json:"api_config_path,omitempty" mapstructure:"api_config_path"`
}
+
+// TimeoutConfig the config of ConnectTimeout and RequestTimeout
+type TimeoutConfig struct {
+ ConnectTimeoutStr string `yaml:"connect_timeout" json:"connect_timeout,omitempty"` // ConnectTimeout timeout for connect to cluster node
+ RequestTimeoutStr string `yaml:"request_timeout" json:"request_timeout,omitempty"`
+}
diff --git a/pkg/model/cluster.go b/pkg/model/cluster.go
index ee53b6f..0877fd2 100644
--- a/pkg/model/cluster.go
+++ b/pkg/model/cluster.go
@@ -19,17 +19,15 @@ package model
// Cluster a single upstream cluster
type Cluster struct {
- Name string `yaml:"name" json:"name"` // Name the cluster unique name
- TypeStr string `yaml:"type" json:"type"` // Type the cluster discovery type string value
- Type DiscoveryType `yaml:",omitempty" json:",omitempty"` // Type the cluster discovery type
- EdsClusterConfig EdsClusterConfig `yaml:"eds_cluster_config" json:"eds_cluster_config" mapstructure:"eds_cluster_config"`
- LbStr string `yaml:"lb_policy" json:"lb_policy"` // Lb the cluster select node used loadBalance policy
- Lb LbPolicy `yaml:",omitempty" json:",omitempty"` // Lb the cluster select node used loadBalance policy
- ConnectTimeoutStr string `yaml:"connect_timeout" json:"connect_timeout"` // ConnectTimeout timeout for connect to cluster node
- HealthChecks []HealthCheck `yaml:"health_checks" json:"health_checks"`
- Hosts []Address `yaml:"hosts" json:"hosts"` // Hosts whe discovery type is Static, StrictDNS or LogicalDns, this need config
- RequestTimeoutStr string `yaml:"request_timeout" json:"request_timeout"`
- Registries map[string]Registry `yaml:"registries" json:"registries"`
+ Name string `yaml:"name" json:"name"` // Name the cluster unique name
+ TypeStr string `yaml:"type" json:"type"` // Type the cluster discovery type string value
+ Type DiscoveryType `yaml:",omitempty" json:",omitempty"` // Type the cluster discovery type
+ EdsClusterConfig EdsClusterConfig `yaml:"eds_cluster_config" json:"eds_cluster_config" mapstructure:"eds_cluster_config"`
+ LbStr string `yaml:"lb_policy" json:"lb_policy"` // Lb the cluster select node used loadBalance policy
+ Lb LbPolicy `yaml:",omitempty" json:",omitempty"` // Lb the cluster select node used loadBalance policy
+ HealthChecks []HealthCheck `yaml:"health_checks" json:"health_checks"`
+ Hosts []Address `yaml:"hosts" json:"hosts"` // Hosts whe discovery type is Static, StrictDNS or LogicalDns, this need config
+ Registries map[string]Registry `yaml:"registries" json:"registries"`
}
// DiscoveryType
diff --git a/samples/admin/proxy/conf.yaml b/samples/admin/proxy/conf.yaml
index b18a5e0..2f6736a 100644
--- a/samples/admin/proxy/conf.yaml
+++ b/samples/admin/proxy/conf.yaml
@@ -64,8 +64,6 @@ static_resources:
clusters:
- name: "test_dubbo"
lb_policy: "RoundRobin"
- connect_timeout: "5s"
- request_timeout: "10s"
registries:
"zookeeper":
timeout: "3s"
@@ -75,6 +73,9 @@ static_resources:
# "consul":
# timeout: "3s"
# address: "127.0.0.1:8500"
+ timeout_config:
+ connect_timeout: "5s"
+ request_timeout: "10s"
shutdown_config:
timeout: "60s"
step_timeout: "10s"
diff --git a/samples/dubbogo/http/pixiu/conf.yaml b/samples/dubbogo/http/pixiu/conf.yaml
index 6f353a8..95f6231 100644
--- a/samples/dubbogo/http/pixiu/conf.yaml
+++ b/samples/dubbogo/http/pixiu/conf.yaml
@@ -32,8 +32,6 @@ static_resources:
clusters:
- name: "test_dubbo"
lb_policy: "RoundRobin"
- connect_timeout: "5s"
- request_timeout: "10s"
registries:
"zookeeper":
protocol: "zookeeper"
@@ -44,6 +42,9 @@ static_resources:
# "consul":
# timeout: "3s"
# address: "127.0.0.1:8500"
+ timeout_config:
+ connect_timeout: "5s"
+ request_timeout: "10s"
shutdown_config:
timeout: "60s"
step_timeout: "10s"
diff --git a/samples/dubbogo/multi/config/conf.yaml b/samples/dubbogo/multi/config/conf.yaml
index 5691e98..07fe310 100644
--- a/samples/dubbogo/multi/config/conf.yaml
+++ b/samples/dubbogo/multi/config/conf.yaml
@@ -63,8 +63,6 @@ static_resources:
clusters:
- name: "test_dubbo"
lb_policy: "RoundRobin"
- connect_timeout: "5s"
- request_timeout: "10s"
registries:
"zookeeper1":
protocol: "zookeeper"
@@ -74,6 +72,9 @@ static_resources:
protocol: "zookeeper"
timeout: "3s"
address: "127.0.0.1:2182"
+ timeout_config:
+ connect_timeout: "5s"
+ request_timeout: "10s"
shutdown_config:
timeout: "60s"
step_timeout: "10s"
diff --git a/samples/dubbogo/simple/body/conf.yaml b/samples/dubbogo/simple/body/conf.yaml
index beb8e64..6e65bf5 100644
--- a/samples/dubbogo/simple/body/conf.yaml
+++ b/samples/dubbogo/simple/body/conf.yaml
@@ -32,14 +32,15 @@ static_resources:
clusters:
- name: "test_dubbo"
lb_policy: "RoundRobin"
- connect_timeout: "5s"
- request_timeout: "10s"
registries:
"zookeeper":
timeout: "3s"
address: "127.0.0.1:2181"
username: ""
password: ""
+ timeout_config:
+ connect_timeout: "5s"
+ request_timeout: "10s"
shutdown_config:
timeout: "60s"
step_timeout: "10s"
diff --git a/samples/dubbogo/simple/mix/conf.yaml b/samples/dubbogo/simple/mix/conf.yaml
index 7f98a78..0d61e23 100644
--- a/samples/dubbogo/simple/mix/conf.yaml
+++ b/samples/dubbogo/simple/mix/conf.yaml
@@ -32,14 +32,15 @@ static_resources:
clusters:
- name: "test_dubbo"
lb_policy: "RoundRobin"
- connect_timeout: "5s"
- request_timeout: "10s"
registries:
"zookeeper":
timeout: "3s"
address: "127.0.0.1:2181"
username: ""
password: ""
+ timeout_config:
+ connect_timeout: "5s"
+ request_timeout: "10s"
shutdown_config:
timeout: "60s"
step_timeout: "10s"
diff --git a/samples/dubbogo/simple/proxy/conf.yaml b/samples/dubbogo/simple/proxy/conf.yaml
index 010769f..44e1974 100644
--- a/samples/dubbogo/simple/proxy/conf.yaml
+++ b/samples/dubbogo/simple/proxy/conf.yaml
@@ -32,14 +32,15 @@ static_resources:
clusters:
- name: "test_dubbo"
lb_policy: "RoundRobin"
- connect_timeout: "5s"
- request_timeout: "10s"
registries:
"zookeeper":
timeout: "3s"
address: "127.0.0.1:2181"
username: ""
password: ""
+ timeout_config:
+ connect_timeout: "5s"
+ request_timeout: "10s"
shutdown_config:
timeout: "60s"
step_timeout: "10s"
diff --git a/samples/dubbogo/simple/query/conf.yaml b/samples/dubbogo/simple/query/conf.yaml
index 6631744..6c35f16 100644
--- a/samples/dubbogo/simple/query/conf.yaml
+++ b/samples/dubbogo/simple/query/conf.yaml
@@ -32,14 +32,15 @@ static_resources:
clusters:
- name: "test_dubbo"
lb_policy: "RoundRobin"
- connect_timeout: "5s"
- request_timeout: "10s"
registries:
"zookeeper":
timeout: "3s"
address: "127.0.0.1:2181"
username: ""
password: ""
+ timeout_config:
+ connect_timeout: "5s"
+ request_timeout: "10s"
shutdown_config:
timeout: "60s"
step_timeout: "10s"
diff --git a/samples/dubbogo/simple/uri/conf.yaml b/samples/dubbogo/simple/uri/conf.yaml
index 2067be4..af60e20 100644
--- a/samples/dubbogo/simple/uri/conf.yaml
+++ b/samples/dubbogo/simple/uri/conf.yaml
@@ -32,14 +32,15 @@ static_resources:
clusters:
- name: "test_dubbo"
lb_policy: "RoundRobin"
- connect_timeout: "5s"
- request_timeout: "10s"
registries:
"zookeeper":
timeout: "3s"
address: "127.0.0.1:2181"
username: ""
password: ""
+ timeout_config:
+ connect_timeout: "5s"
+ request_timeout: "10s"
shutdown_config:
timeout: "60s"
step_timeout: "10s"
diff --git a/samples/plugins/config/conf.yaml b/samples/plugins/config/conf.yaml
index bde9d5f..c966192 100644
--- a/samples/plugins/config/conf.yaml
+++ b/samples/plugins/config/conf.yaml
@@ -32,8 +32,6 @@ static_resources:
clusters:
- name: "test_dubbo"
lb_policy: "RoundRobin"
- connect_timeout: "5s"
- request_timeout: "10s"
registries:
"zookeeper":
timeout: "3s"
@@ -43,6 +41,9 @@ static_resources:
# "consul":
# timeout: "3s"
# address: "127.0.0.1:8500"
+ timeout_config:
+ connect_timeout: "5s"
+ request_timeout: "10s"
shutdown_config:
timeout: "60s"
step_timeout: "10s"