Skip to content
Discussion options

You must be logged in to vote

结论:PropertiesCompatibleFileConfigRepository 主要是给 YAML/YML 这类“文件内容需要先转换成 Properties”的格式用的,Properties 类型本身已经是 key-value Properties,所以 Config#getProperty 读取时应走普通 ConfigRepository 链路,而不是再绕一层 ConfigFile 适配。

当前链路大致是:

  • DefaultConfigFactory#create(...) 会先通过 determineFileFormat(namespace) 判断格式。只有 ConfigFileFormat.isPropertiesCompatible(format)format != ConfigFileFormat.Properties 时,才会创建 PropertiesCompatibleFileConfigRepository
  • 对 Properties 类型,RemoteConfigRepository#getConfig() 已经直接把 ApolloConfig#getConfigurations() 转成 PropertiesDefaultConfig 可以直接消费这份 key-value 数据。
  • 对 YAML/YML 类型,服务端返回的是文件内容,客户端会通过 PlainTextConfigFile#getContent() 读取 content 字段,再由 YamlConfigFile#asProperties() 调用 YamlParser#yam…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@yfwz100
Comment options

Answer selected by yfwz100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants