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

feat: advanced mapping with support for splitting configurations into multiple files. #141

Merged
merged 2 commits into from
Sep 22, 2024

Conversation

Zerorigin
Copy link
Contributor

advanced mapping添加“支持将配置拆分到多个配置文件”的特性

功能介绍:
1、共用原有的 -c, --config 命令选项,不破坏已有的行为
2、当传参为文件路径时,按照以前的逻辑进行处理
3、当传参为目录路径时,会递归查找指定目录及其子目录(未限制深度,并且会自动跟链接符号)下的jsontoml配置文件(支持混合目录)
4、所有配置文件按照advanced mapping的配置尝试进行解析和简单的合并(无去重行为,需使用者自行处理),解析失败则报错退出程序
5、当传参为目录路径时,且混入LegacyConf配置文件时,解析到此文件会报错退出程序(需使用者自行剔除)
6、当初始化 EndPoint 时,遇到在同一 IP 地址和端口重复监听时,则报错退出(需使用者自行剔除重复项)

@Zerorigin
Copy link
Contributor Author

#135 #139 这两个 issue 可以随这个 pr 合并后一起关闭

@zephyrchien
Copy link
Collaborator

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.

@Zerorigin
Copy link
Contributor Author

Zerorigin commented Sep 17, 2024

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 所提到的,其实它们( #108 #129 #135 )旨在解决一个共同问题:
使用 realm 管理太多服务转发端口时,单一配置文件过于冗长而导致的心智压力,毕竟人不是机器。
虽说初次增加配置时可能还好,但后续变更或者删减,不得不在修改配置文件时极其的细心谨慎,这种压力令人很不开心。

另一点正如您所看到的,此段代码的侵入性并不大,合不合并它,都不会导致代码维护的繁琐性和重构的难度明显变大。

它可以作为在 HTTP API 尚未实现的情况下的一种过渡方案,也希望后续在实现 HTTP API 时能考虑到对配置进行分组过滤的情景。

@zephyrchien
Copy link
Collaborator

Okay! Let's try to merge this PR then.

@zephyrchien zephyrchien merged commit e299df3 into zhboner:master Sep 22, 2024
1 of 21 checks passed
@zephyrchien
Copy link
Collaborator

@Zerorigin
I made some small modifications. Thank you for putting up this feature!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants