Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #1323 delete zk registry when set defualt consumer/provider config #1324

Merged
merged 1 commit into from
Jul 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions common/constant/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,3 @@ const (
DEFAULT_LOG_CONF_FILE_PATH = "../profiles/dev/log.yml"
DEFAULT_ROUTER_CONF_FILE_PATH = "../profiles/dev/router.yml"
)

// default config value
const (
DEFAULT_REGISTRY_ZK_ID = "demoZK"
DEFAULT_REGISTRY_ZK_PROTOCOL = ZOOKEEPER_KEY
DEFAULT_REGISTRY_ZK_TIMEOUT = "3s"
DEFAULT_REGISTRY_ZK_ADDRESS = "127.0.0.1:2181"
)
11 changes: 0 additions & 11 deletions config/config_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,9 @@ func DefaultInit() []LoaderInitOption {

// setDefaultValue set default value for providerConfig or consumerConfig if it is null
func setDefaultValue(target interface{}) {
registryConfig := &RegistryConfig{
Protocol: constant.DEFAULT_REGISTRY_ZK_PROTOCOL,
TimeoutStr: constant.DEFAULT_REGISTRY_ZK_TIMEOUT,
Address: constant.DEFAULT_REGISTRY_ZK_ADDRESS,
}
switch target.(type) {
case *ProviderConfig:
p := target.(*ProviderConfig)
if len(p.Registries) == 0 && p.Registry == nil {
p.Registries[constant.DEFAULT_REGISTRY_ZK_ID] = registryConfig
}
if len(p.Protocols) == 0 {
p.Protocols[constant.DEFAULT_PROTOCOL] = &ProtocolConfig{
Name: constant.DEFAULT_PROTOCOL,
Expand All @@ -117,9 +109,6 @@ func setDefaultValue(target interface{}) {
}
default:
c := target.(*ConsumerConfig)
if len(c.Registries) == 0 && c.Registry == nil {
c.Registries[constant.DEFAULT_REGISTRY_ZK_ID] = registryConfig
}
if c.ApplicationConfig == nil {
c.ApplicationConfig = NewDefaultApplicationConfig()
}
Expand Down
6 changes: 0 additions & 6 deletions config/config_loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,19 +207,13 @@ func TestSetDefaultValue(t *testing.T) {
proConfig := &ProviderConfig{Registries: make(map[string]*RegistryConfig), Protocols: make(map[string]*ProtocolConfig)}
assert.Nil(t, proConfig.ApplicationConfig)
setDefaultValue(proConfig)
assert.Equal(t, proConfig.Registries["demoZK"].Address, "127.0.0.1:2181")
assert.Equal(t, proConfig.Registries["demoZK"].TimeoutStr, "3s")
assert.Equal(t, proConfig.Registries["demoZK"].Protocol, "zookeeper")
assert.Equal(t, proConfig.Protocols["dubbo"].Name, "dubbo")
assert.Equal(t, proConfig.Protocols["dubbo"].Port, "20000")
assert.NotNil(t, proConfig.ApplicationConfig)

conConfig := &ConsumerConfig{Registries: make(map[string]*RegistryConfig)}
assert.Nil(t, conConfig.ApplicationConfig)
setDefaultValue(conConfig)
assert.Equal(t, conConfig.Registries["demoZK"].Address, "127.0.0.1:2181")
assert.Equal(t, conConfig.Registries["demoZK"].TimeoutStr, "3s")
assert.Equal(t, conConfig.Registries["demoZK"].Protocol, "zookeeper")
assert.NotNil(t, conConfig.ApplicationConfig)

}
Expand Down
4 changes: 2 additions & 2 deletions config/reference_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ func (c *ReferenceConfig) Refer(_ interface{}) {

if len(c.urls) == 1 {
c.invoker = extension.GetProtocol(c.urls[0].Protocol).Refer(c.urls[0])
// c.URL != "" is direct call
// c.URL != "" is direct call, and will overide c.invoker
if c.URL != "" {
//filter
// filter
c.invoker = protocolwrapper.BuildInvokerChain(c.invoker, constant.REFERENCE_FILTER_KEY)

// cluster
Expand Down