TogetherOS / cicada

🚀 Fast lightweight HTTP service framework.
https://crossoverjie.top/categories/cicada/
Apache License 2.0
953 stars 212 forks source link

增加 yml 配置文件的 port/path 读取 #5

Closed LiWenGu closed 6 years ago

LiWenGu commented 6 years ago

参考 org.springframework.beans.factory.config.YamlProcessor,粗陋的实现,感觉如果要易扩展,还缺少两个:

  1. 类似统一资源管理 Resource 的接口
  2. 反射工具类,根据 set 方法赋值

    还在看 Spring Resource 和 Reflect 源码中,想办法如何整合到 Cicada 中。

另外考虑到,AppConfig 是单例,获取 getInstance,就没有使用反射,直接使用的 getInstance,缺点在于如果增加了一个项配置,则需要在源码中增加一行 set 方法,优点在于不需要反射啦。 另外还有多配置文件的读取也没有实现。

crossoverJie commented 6 years ago

@LiWenGu

读取配置文件这块内容截止 v1.0.1 版本还没有想到具体的实现。

但是我初步的设想是读取 *.properties ,而不是 ymlyml 给我的感觉不是特别清晰,虽然现在 Spring 也支持这样的方式。

Cicada 默认是应该是读取 classpath 中的 application.properties。如果需要自定义配置;只需要实现特定接口定义好配置文件名称即可。

同时也得支持外置文件,方便不同环境。

这块具体的实现还在考虑中,多谢本次 PR。

就代码层面还是可以沟通的,比如打日志这些。

具体请参考: vjtools

随便提下,希望大家参与时使用英文。不管是 issue、注释、PR 描述等,坚持下去肯定对大家有好处。

LiWenGu commented 6 years ago

Thank you. I will read the VJTools carefully. My code is really not standard enough,

no bad smells in code

crossoverJie commented 6 years ago

@LiWenGu

Expect better PR.