| """ | |
| 实体信息结构 | |
| """ | |
| from dataclasses import dataclass | |
| from typing import Optional | |
| import uuid | |
| class EntityInfo: | |
| """主体信息结构""" | |
| id: str # UUID格式唯一标识 | |
| name: str # 显示名称 | |
| redis_host: str # Redis服务器地址 | |
| redis_port: int # Redis端口 | |
| redis_db: int # Redis数据库编号 | |
| channel: str # 订阅channel名称 | |
| def __post_init__(self): | |
| """数据验证""" | |
| if not self.id: | |
| self.id = str(uuid.uuid4()) | |
| if not self.channel: | |
| self.channel = self.id |