You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, @uucloud! I'm here to help you with your Apollo configuration issue. Let's work together to solve this!
To achieve consistent behavior for both JSON and YAML configurations in Apollo when using Kratos, you can follow these steps:
Without WithOriginalConfig:
For YAML, you can directly use multi-level keys like server.name for both Scan and Watch.
For JSON, you need to use the .content suffix to access the configuration, and it doesn't support multi-level keys directly. You can only watch the entire content using js.content.
With WithOriginalConfig:
Both JSON and YAML configurations can be scanned directly without specifying keys, which makes the Scan usage consistent.
However, Watch becomes limited because there is no root key. You can only watch specific sub-keys like server.name, but not the entire file.
To achieve your goal of having consistent Scan and Watch usage for both JSON and YAML, you might need to implement a custom solution that handles the differences in how JSON and YAML are processed. This could involve:
Implementing a custom change listener that can handle both formats uniformly.
Modifying the way keys are generated and watched to support both entire file changes and specific key changes.
The customChangeListener in the watcher.go file can be a good starting point for handling changes and resolving keys consistently across different formats [1].
使用apollo配置中心结合kratos时存在一个令人困惑的地方:
我的配置是这样的:
yaml的配置是这样的 bootstrap.yaml:
json的配置是这样的 js.json:
当我不开启WithOriginalConfig时,yaml和json的Scan的方式有些不同,比如:
而当我开启WithOriginalConfig后,json和yaml的Scan用法一样了,但是Watch没有最外层的key,也就是不可以config.Watch("bootstrap"),导致不能Watch整个文件的变化了
是我的使用方式不对吗,我期望的是,json和yaml的Scan使用方式一致,Watch都可以Watch多级子key的同时,也可以Watch整个文件的变化
The text was updated successfully, but these errors were encountered: