apache / apache/dubbo

[3.0] Meaningless/Confusing "key" in dynamic config's yaml

Open
#8,370 2 comments 0 reactions 0 assignees View on GitHub
status/waiting-for-feedback type/proposal
Dominant language
Java
Stars
41.6k
Forks
26.4k
Avg merge
15h 13m
Merged PRs (30d)
4

Description

- [x] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate.
- [x] I have checked the [FAQ](https://github.com/apache/dubbo/blob/master/FAQ.md) of this repository and believe that this is not a duplicate.

### Environment

* Dubbo version: 3.0.2-SNAPSHOT
* Operating System version: ANY
* Java version: 8

### Steps to reproduce this issue

服务提供者端,传统服务发现模式,配置中心使用zookeeper或者apollo,注册2个服务
```

```

消费者启动后,会在配置中心监节点级别的动态配置和服务级别的动态配置,以zookeeper为例,会监听:

1. 节点级,path=/dubbo/config/dubbo/demo-provider.configurators
2. 服务级,path=/dubbo/config/dubbo/org.apache.dubbo.demo.DemoService:1.2.3:G1.configurators
3. 服务级,path=/dubbo/config/dubbo/org.apache.dubbo.demo.GreetingService:4.5.6:G2.configurators

#### 场景1,节点级配置

向`/dubbo/config/dubbo/demo-provider.configurators`写入DemoService的动态配置
```
configVersion: v2.7
scope: service
key: G1/org.apache.dubbo.demo.DemoService:1.2.3
configs:
- addresses: ['0.0.0.0:20880']
side: provider
parameters:
weight: 222
```
根据提供者reExport日志,发现DemoService和GreetingService都按weight=222进行了重新注册。

#### 场景2,服务级配置

向`/dubbo/config/dubbo/org.apache.dubbo.demo.DemoService:1.2.3:G1.configurators`写入DemoService的动态配置
```
configVersion: v2.7
scope: service
key: AAAAA <--瞎写就行
configs:
- addresses: ['0.0.0.0:20880']
side: provider
parameters:
weight: 333
```
根据提供者reExport日志,发现DemoService按weight=333进行了重新注册。

#### 总结

1. 可以发现yaml中的key没有实际存在的意义,因为key中的服务信息,在DynamicConfiguration实现,以及ConfigChangeListener中都有,在AbstractConfiguratorListener#genConfiguratorsFromRawRule传入即可。此处key属性可取消。
2. 作为scope: service的配置,写入节点级配置路径也能生效,此处最好能控制监听逻辑。节点级只响应scope:application的yaml,服务级只响应scope:service的yaml,或者也可取消scope属性。

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.