refactor(config): 重构配置模块并优化应用依赖注入
- 将配置相关类移动到model模块 - 实现依赖注入容器管理各组件依赖关系 - 重构配置加载逻辑支持多层级键值查找 - 更新主应用入口支持命令行参数解析 - 统一日志输出格式替换原有打印语句 - 引入钻井实时数据模型简化数据处理 - 移除硬编码字段映射改用动态配置方式 - 优化数据库写入逻辑基于新的数据模型
This commit is contained in:
@@ -1,40 +1,12 @@
|
||||
from dataclasses import dataclass
|
||||
from model import AppConfig, MqttConfig, TdengineConfig, TmsConfig, WitsConfig
|
||||
|
||||
Config = AppConfig
|
||||
|
||||
@dataclass
|
||||
class MqttConfig:
|
||||
broker: str
|
||||
client_id: str
|
||||
mock_client_id: str
|
||||
sender_client_id: str
|
||||
subscriber_client_id: str
|
||||
username: str
|
||||
password: str
|
||||
pub_topic: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class TmsConfig:
|
||||
device_code: str
|
||||
equipment_sn: str
|
||||
timeout: int
|
||||
keepalive: int
|
||||
server_ip: str
|
||||
server_port: int
|
||||
|
||||
|
||||
@dataclass
|
||||
class TdengineConfig:
|
||||
url: str
|
||||
username: str
|
||||
password: str
|
||||
database: str
|
||||
stable: str
|
||||
device_code: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class Config:
|
||||
mqtt: MqttConfig
|
||||
tms: TmsConfig
|
||||
tdengine: TdengineConfig
|
||||
__all__ = [
|
||||
"Config",
|
||||
"AppConfig",
|
||||
"MqttConfig",
|
||||
"TdengineConfig",
|
||||
"TmsConfig",
|
||||
"WitsConfig",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user