将config的初始化在CreateAPP时执行,并且可以传入初始化好的conf来自由载入conf #50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
修改了App的初始化逻辑:
原来:app的setting是在Run方法执行时载入的,通过conf的LoadConfig方法
现在:app的setting是在Create时载入的,并且可以传入已经load好的conf.Config对象,来跳过从硬盘读取
影响:
为了提前初始化conf,将参数debug也一并移动到了CreateAPP方法中,所以原来在run时才传的debug参数现在要移到CreateAPP的时候传入
CreateAPP的参数除了debug,还可以传入其他选项,当前实现了传入conf.Config对象,可以直接以此作为setting来创建app:
以这种方式传入options可以使app变得更为灵活
例如,以后可以把logger也作为一个实例化好的对象直接传入(入未传入则使用默认的),然后app内部需要log时直接调用
app.logger.Debug("something")
这样,可以进一步解耦,我们只需要定一个log Interface,这样可以很方便的对接到三方logger方案并且非常优雅望采纳
希望mqant越加强大