LoadFileConfig 如果指定配置文件,初始化配置
(configFile string, confType ...interface{})
| 101 | |
| 102 | // LoadFileConfig 如果指定配置文件,初始化配置 |
| 103 | func (service *TaskService) LoadFileConfig(configFile string, confType ...interface{}) *TaskService { |
| 104 | cType := ConfigType_Xml |
| 105 | if len(confType) > 0 && confType[0] == ConfigType_Json { |
| 106 | cType = ConfigType_Json |
| 107 | } |
| 108 | if len(confType) > 0 && confType[0] == ConfigType_Yaml { |
| 109 | cType = ConfigType_Yaml |
| 110 | } |
| 111 | var config *AppConfig |
| 112 | if cType == ConfigType_Json { |
| 113 | config = JsonConfigHandler(configFile) |
| 114 | } else if cType == ConfigType_Yaml { |
| 115 | config = YamlConfigHandler(configFile) |
| 116 | } else { |
| 117 | config = XmlConfigHandler(configFile) |
| 118 | } |
| 119 | service.applyConfig(config) |
| 120 | return service |
| 121 | } |
| 122 | |
| 123 | // applyConfig apply task config with AppConfig |
| 124 | func (service *TaskService) applyConfig(config *AppConfig) *TaskService { |
no test coverage detected