Skip to content

Commit

Permalink
Merge branch 'develop' into bugfix-reset
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexStocks authored Sep 24, 2021
2 parents 040557f + fb16f72 commit 7d8d8ba
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 68 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/alibaba/sentinel-golang v1.0.2
github.com/apache/dubbo-go v1.5.7-rc2
github.com/apache/dubbo-go-hessian2 v1.9.3
github.com/creasty/defaults v1.5.2
github.com/dubbogo/dubbo-go-pixiu-filter v0.1.4
github.com/dubbogo/go-zookeeper v1.0.3
github.com/dubbogo/gost v1.11.14
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creasty/defaults v1.5.1 h1:j8WexcS3d/t4ZmllX4GEkl4wIB/trOr035ajcLHCISM=
github.com/creasty/defaults v1.5.1/go.mod h1:FPZ+Y0WNrbqOVw+c6av63eyHUAl6pMHZwqLPvXUZGfY=
github.com/creasty/defaults v1.5.2 h1:/VfB6uxpyp6h0fr7SPp7n8WJBoV8jfxQXPCnkVSjyls=
github.com/creasty/defaults v1.5.2/go.mod h1:FPZ+Y0WNrbqOVw+c6av63eyHUAl6pMHZwqLPvXUZGfY=
github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down
5 changes: 4 additions & 1 deletion pkg/config/config_load.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
)

import (
"github.com/creasty/defaults"
"github.com/ghodss/yaml"

"github.com/goinggo/mapstructure"
)

Expand Down Expand Up @@ -87,6 +87,9 @@ func LoadYAMLConfig(path string) *model.Bootstrap {
if err != nil {
log.Fatalln("[config] [yaml load] convert YAML to JSON failed, ", err)
}
if err = defaults.Set(cfg); err != nil {
log.Fatalln("[config] [yaml load] initialize structs with default value failed, ", err)
}
err = Adapter(cfg)
if err != nil {
log.Fatalln("[config] [yaml load] yaml unmarshal config failed, ", err)
Expand Down
6 changes: 3 additions & 3 deletions pkg/model/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ type (
// management servers
SocketAddress struct {
ProtocolStr string `yaml:"protocol_type" json:"protocol_type" mapstructure:"protocol_type"`
Protocol ProtocolType `yaml:"omitempty" json:"omitempty"`
Address string `yaml:"address" json:"address" mapstructure:"address"`
Port int `yaml:"port" json:"port" mapstructure:"port"`
Protocol ProtocolType `default:"http" yaml:"omitempty" json:"omitempty"`
Address string `default:"0.0.0.0" yaml:"address" json:"address" mapstructure:"address"`
Port int `default:"8881" yaml:"port" json:"port" mapstructure:"port"`
ResolverName string `yaml:"resolver_name" json:"resolver_name" mapstructure:"resolver_name"`
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/model/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type DynamicResources struct{}
type ShutdownConfig struct {
Timeout string `default:"60s" yaml:"timeout" json:"timeout,omitempty"`
StepTimeout string `default:"10s" yaml:"step_timeout" json:"step_timeout,omitempty"`
RejectPolicy string `yaml:"reject_policy" json:"reject_policy,omitempty"`
RejectPolicy string `default:"immediacy" yaml:"reject_policy" json:"reject_policy,omitempty"`
}

// APIMetaConfig how to find api config, file or etcd etc.
Expand All @@ -80,6 +80,6 @@ type APIMetaConfig struct {

// 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"`
ConnectTimeoutStr string `default:"5s" yaml:"connect_timeout" json:"connect_timeout,omitempty"` // ConnectTimeout timeout for connect to cluster node
RequestTimeoutStr string `default:"10s" yaml:"request_timeout" json:"request_timeout,omitempty"`
}
2 changes: 1 addition & 1 deletion pkg/model/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type (

// Registry remote registry where dubbo apis are registered.
Registry struct {
Protocol string `yaml:"protocol" json:"protocol" default:"zookeeper"`
Protocol string `default:"zookeeper" yaml:"protocol" json:"protocol"`
Timeout string `yaml:"timeout" json:"timeout"`
Address string `yaml:"address" json:"address"`
Username string `yaml:"username" json:"username"`
Expand Down
88 changes: 28 additions & 60 deletions samples/dubbogo/simple/body/pixiu/conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,64 +20,32 @@
static_resources:
listeners:
- name: "net/http"
address:
socket_address:
protocol_type: "HTTP"
address: "0.0.0.0"
port: 8881
filter_chains:
- filter_chain_match:
domains:
- api.dubbo.com
- api.pixiu.com
filters:
- name: dgp.filter.httpconnectionmanager
config:
route_config:
routes:
- match:
prefix: "/api/v1"
route:
cluster: "test-dubbo"
cluster_not_found_response_code: 505
http_filters:
- name: dgp.filter.http.apiconfig
config:
path: $PROJECT_DIR/pixiu/api_config.yaml
- name: dgp.filter.http.dubboproxy
config:
dubboProxyConfig:
registries:
"zookeeper":
protocol: "zookeeper"
timeout: "3s"
address: "127.0.0.1:2181"
username: ""
password: ""
timeout_config:
connect_timeout: 5s
request_timeout: 5s
- name: dgp.filter.http.response
config:
server_name: "test_http_dubbo"
generate_request_id: false
config:
idle_timeout: 5s
read_timeout: 5s
write_timeout: 5s
clusters:
- name: "test_dubbo"
lb_policy: "RoundRobin"
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"
reject_policy: "immediacy"
- filters:
- name: dgp.filter.httpconnectionmanager
config:
route_config:
routes:
- match:
prefix: "/api/v1"
http_filters:
- name: dgp.filter.http.apiconfig
config:
path: $PROJECT_DIR/pixiu/api_config.yaml
- name: dgp.filter.http.dubboproxy
config:
dubboProxyConfig:
registries:
"zookeeper":
protocol: "zookeeper"
timeout: "3s"
address: "127.0.0.1:2181"
username: ""
password: ""
timeout_config:
connect_timeout: 5s
request_timeout: 5s
- name: dgp.filter.http.response
config:
server_name: "test_http_dubbo"
generate_request_id: false

0 comments on commit 7d8d8ba

Please sign in to comment.