Closed Zerorigin closed 2 months ago
https://github.com/zhboner/realm/issues/135 https://github.com/zhboner/realm/issues/139 这两个 issue 可以随这个 pr 合并后一起关闭
Thanks for your great work and the code looks good to me.
I hesitate to merge this PR because personally I dont think we should spend time on config file stuffs -- It endlessly brings features just for the convenience of some special use case, as well as edge cases which make the codebase hard to maintain.
The current implementation is just a plain & readable view of the internal endpoint::Config
, it has basically covered ALL use cases.
Thanks for your great work and the code looks good to me.
I hesitate to merge this PR because personally I dont think we should spend time on config file stuffs -- It endlessly brings features just for the convenience of some special use case, as well as edge cases which make the codebase hard to maintain.
The current implementation is just a plain & readable view of the internal
endpoint::Config
, it has basically covered ALL use cases.
我希望这个请求被合并。
就像其它 issues 所提到的,其实它们( https://github.com/zhboner/realm/issues/108 https://github.com/zhboner/realm/issues/129 https://github.com/zhboner/realm/issues/135 )旨在解决一个共同问题: 使用 realm 管理太多服务转发端口时,单一配置文件过于冗长而导致的心智压力,毕竟人不是机器。 虽说初次增加配置时可能还好,但后续变更或者删减,不得不在修改配置文件时极其的细心谨慎,这种压力令人很不开心。
另一点正如您所看到的,此段代码的侵入性并不大,合不合并它,都不会导致代码维护的繁琐性和重构的难度明显变大。
它可以作为在 HTTP API 尚未实现的情况下的一种过渡方案,也希望后续在实现 HTTP API 时能考虑到对配置进行分组过滤的情景。
Okay! Let's try to merge this PR then.
@Zerorigin I made some small modifications. Thank you for putting up this feature!
为
advanced mapping
添加“支持将配置拆分到多个配置文件”的特性功能介绍: 1、共用原有的
-c, --config
命令选项,不破坏已有的行为 2、当传参为文件路径时,按照以前的逻辑进行处理 3、当传参为目录路径时,会递归查找指定目录及其子目录(未限制深度,并且会自动跟链接符号)下的json
和toml
配置文件(支持混合目录) 4、所有配置文件按照advanced mapping
的配置尝试进行解析和简单的合并(无去重行为,需使用者自行处理),解析失败则报错退出程序 5、当传参为目录路径时,且混入LegacyConf
配置文件时,解析到此文件会报错退出程序(需使用者自行剔除) 6、当初始化 EndPoint 时,遇到在同一 IP 地址和端口重复监听时,则报错退出(需使用者自行剔除重复项)