fix: auto-fix code issues (cron)
- 修复重复导入/字段 - 修复异常处理 - 修复PEP8格式问题 - 添加类型注解
This commit is contained in:
@@ -29,7 +29,6 @@ import httpx
|
||||
# Database path
|
||||
DB_PATH = os.path.join(os.path.dirname(__file__), "insightflow.db")
|
||||
|
||||
|
||||
class AlertSeverity(StrEnum):
|
||||
"""告警严重级别 P0-P3"""
|
||||
|
||||
@@ -38,7 +37,6 @@ class AlertSeverity(StrEnum):
|
||||
P2 = "p2" # 一般 - 部分功能受影响,需要4小时内处理
|
||||
P3 = "p3" # 轻微 - 非核心功能问题,24小时内处理
|
||||
|
||||
|
||||
class AlertStatus(StrEnum):
|
||||
"""告警状态"""
|
||||
|
||||
@@ -47,7 +45,6 @@ class AlertStatus(StrEnum):
|
||||
ACKNOWLEDGED = "acknowledged" # 已确认
|
||||
SUPPRESSED = "suppressed" # 已抑制
|
||||
|
||||
|
||||
class AlertChannelType(StrEnum):
|
||||
"""告警渠道类型"""
|
||||
|
||||
@@ -60,7 +57,6 @@ class AlertChannelType(StrEnum):
|
||||
SMS = "sms"
|
||||
WEBHOOK = "webhook"
|
||||
|
||||
|
||||
class AlertRuleType(StrEnum):
|
||||
"""告警规则类型"""
|
||||
|
||||
@@ -69,7 +65,6 @@ class AlertRuleType(StrEnum):
|
||||
PREDICTIVE = "predictive" # 预测性告警
|
||||
COMPOSITE = "composite" # 复合告警
|
||||
|
||||
|
||||
class ResourceType(StrEnum):
|
||||
"""资源类型"""
|
||||
|
||||
@@ -82,7 +77,6 @@ class ResourceType(StrEnum):
|
||||
CACHE = "cache"
|
||||
QUEUE = "queue"
|
||||
|
||||
|
||||
class ScalingAction(StrEnum):
|
||||
"""扩缩容动作"""
|
||||
|
||||
@@ -90,7 +84,6 @@ class ScalingAction(StrEnum):
|
||||
SCALE_DOWN = "scale_down" # 缩容
|
||||
MAINTAIN = "maintain" # 保持
|
||||
|
||||
|
||||
class HealthStatus(StrEnum):
|
||||
"""健康状态"""
|
||||
|
||||
@@ -99,7 +92,6 @@ class HealthStatus(StrEnum):
|
||||
UNHEALTHY = "unhealthy"
|
||||
UNKNOWN = "unknown"
|
||||
|
||||
|
||||
class BackupStatus(StrEnum):
|
||||
"""备份状态"""
|
||||
|
||||
@@ -109,7 +101,6 @@ class BackupStatus(StrEnum):
|
||||
FAILED = "failed"
|
||||
VERIFIED = "verified"
|
||||
|
||||
|
||||
@dataclass
|
||||
class AlertRule:
|
||||
"""告警规则"""
|
||||
@@ -133,7 +124,6 @@ class AlertRule:
|
||||
updated_at: str
|
||||
created_by: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class AlertChannel:
|
||||
"""告警渠道配置"""
|
||||
@@ -151,7 +141,6 @@ class AlertChannel:
|
||||
created_at: str
|
||||
updated_at: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class Alert:
|
||||
"""告警实例"""
|
||||
@@ -175,7 +164,6 @@ class Alert:
|
||||
notification_sent: dict[str, bool] # 渠道发送状态
|
||||
suppression_count: int # 抑制计数
|
||||
|
||||
|
||||
@dataclass
|
||||
class AlertSuppressionRule:
|
||||
"""告警抑制规则"""
|
||||
@@ -189,7 +177,6 @@ class AlertSuppressionRule:
|
||||
created_at: str
|
||||
expires_at: str | None
|
||||
|
||||
|
||||
@dataclass
|
||||
class AlertGroup:
|
||||
"""告警聚合组"""
|
||||
@@ -201,7 +188,6 @@ class AlertGroup:
|
||||
created_at: str
|
||||
updated_at: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class ResourceMetric:
|
||||
"""资源指标"""
|
||||
@@ -216,7 +202,6 @@ class ResourceMetric:
|
||||
timestamp: str
|
||||
metadata: dict
|
||||
|
||||
|
||||
@dataclass
|
||||
class CapacityPlan:
|
||||
"""容量规划"""
|
||||
@@ -232,7 +217,6 @@ class CapacityPlan:
|
||||
estimated_cost: float
|
||||
created_at: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class AutoScalingPolicy:
|
||||
"""自动扩缩容策略"""
|
||||
@@ -253,7 +237,6 @@ class AutoScalingPolicy:
|
||||
created_at: str
|
||||
updated_at: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class ScalingEvent:
|
||||
"""扩缩容事件"""
|
||||
@@ -271,7 +254,6 @@ class ScalingEvent:
|
||||
completed_at: str | None
|
||||
error_message: str | None
|
||||
|
||||
|
||||
@dataclass
|
||||
class HealthCheck:
|
||||
"""健康检查配置"""
|
||||
@@ -292,7 +274,6 @@ class HealthCheck:
|
||||
created_at: str
|
||||
updated_at: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class HealthCheckResult:
|
||||
"""健康检查结果"""
|
||||
@@ -306,7 +287,6 @@ class HealthCheckResult:
|
||||
details: dict
|
||||
checked_at: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class FailoverConfig:
|
||||
"""故障转移配置"""
|
||||
@@ -324,7 +304,6 @@ class FailoverConfig:
|
||||
created_at: str
|
||||
updated_at: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class FailoverEvent:
|
||||
"""故障转移事件"""
|
||||
@@ -340,7 +319,6 @@ class FailoverEvent:
|
||||
completed_at: str | None
|
||||
rolled_back_at: str | None
|
||||
|
||||
|
||||
@dataclass
|
||||
class BackupJob:
|
||||
"""备份任务"""
|
||||
@@ -360,7 +338,6 @@ class BackupJob:
|
||||
created_at: str
|
||||
updated_at: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class BackupRecord:
|
||||
"""备份记录"""
|
||||
@@ -377,7 +354,6 @@ class BackupRecord:
|
||||
error_message: str | None
|
||||
storage_path: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class CostReport:
|
||||
"""成本报告"""
|
||||
@@ -392,7 +368,6 @@ class CostReport:
|
||||
anomalies: list[dict] # 异常检测
|
||||
created_at: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class ResourceUtilization:
|
||||
"""资源利用率"""
|
||||
@@ -408,7 +383,6 @@ class ResourceUtilization:
|
||||
report_date: str
|
||||
recommendations: list[str]
|
||||
|
||||
|
||||
@dataclass
|
||||
class IdleResource:
|
||||
"""闲置资源"""
|
||||
@@ -425,7 +399,6 @@ class IdleResource:
|
||||
recommendation: str
|
||||
detected_at: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class CostOptimizationSuggestion:
|
||||
"""成本优化建议"""
|
||||
@@ -445,7 +418,6 @@ class CostOptimizationSuggestion:
|
||||
created_at: str
|
||||
applied_at: str | None
|
||||
|
||||
|
||||
class OpsManager:
|
||||
"""运维与监控管理主类"""
|
||||
|
||||
@@ -3098,11 +3070,9 @@ class OpsManager:
|
||||
applied_at=row["applied_at"],
|
||||
)
|
||||
|
||||
|
||||
# Singleton instance
|
||||
_ops_manager = None
|
||||
|
||||
|
||||
def get_ops_manager() -> OpsManager:
|
||||
global _ops_manager
|
||||
if _ops_manager is None:
|
||||
|
||||
Reference in New Issue
Block a user