feat(alert): A2 告警引擎分布式安全 — Redis 分布式锁(SetNX)
- Cache 接口新增 SetNX 方法(go-redis 原子 / redka check-then-set 单副本安全) - AlertEngine 改造为支持分布式锁: tryAcquireLock/releaseLock/GetEngineStatus - 多副本部署时仅 Leader 执行告警检查, 60s TTL 防死锁, fail-open 容错 - 新增 GET /alerts/engine/status 监控端点(is_leader/instance_id/lock_holder) - 修复 GrafanaDashboard.tsx Panel.options 类型不匹配导致构建中断 - 同步未提交的前端类型安全迁移(140+ 文件) - ROADMAP/TDD_PLAN/PROJECT_EVALUATION 三文档同步更新 验证: go build 零错误, Docker 部署 healthy, 引擎状态端点正常, 锁竞争测试通过(非 Leader 跳过检查), 5/5 核心 API 回归通过
This commit is contained in:
1 parent
5ca0e6d83a
commit
c68aef4444
150 files changed
+1038
-690
No files matched your search
@@ -17,16 +17,17 @@ import { AlertEventsTab } from './AlertEventsTab';
|
||||
import { AlertRulesTab } from './AlertRulesTab';
|
||||
import { AlertRuleDialog } from './AlertRuleDialog';
|
||||
import { AlertChannelDialog } from './AlertChannelDialog';
|
||||
import type { JsonData } from '@/types/common';
|
||||
|
||||
export function AlertManager() {
|
||||
const [activeTab, setActiveTab] = useState('events');
|
||||
const [alerts, setAlerts] = useState<any[]>([]);
|
||||
const [rules, setRules] = useState<any[]>([]);
|
||||
const [alerts, setAlerts] = useState<JsonData[]>([]);
|
||||
const [rules, setRules] = useState<JsonData[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [ruleDialogOpen, setRuleDialogOpen] = useState(false);
|
||||
const [editingRule, setEditingRule] = useState<any>(null);
|
||||
const [editingRule, setEditingRule] = useState<JsonData>(null);
|
||||
const [channelDialogOpen, setChannelDialogOpen] = useState(false);
|
||||
const [notifyChannels, setNotifyChannels] = useState<any[]>([]);
|
||||
const [notifyChannels, setNotifyChannels] = useState<JsonData[]>([]);
|
||||
|
||||
const loadData = async () => {
|
||||
try {
|
||||
@@ -36,9 +37,9 @@ export function AlertManager() {
|
||||
alertApi.getRules(),
|
||||
alertApi.getNotifyChannels(),
|
||||
]);
|
||||
setAlerts((alertsData as Record<string, any>)?.list || []);
|
||||
setRules((rulesData as Record<string, any>)?.list || (Array.isArray(rulesData) ? rulesData : []));
|
||||
setNotifyChannels((channelsData as Record<string, any>)?.list || []);
|
||||
setAlerts((alertsData as JsonData)?.list || []);
|
||||
setRules((rulesData as JsonData)?.list || (Array.isArray(rulesData) ? rulesData : []));
|
||||
setNotifyChannels((channelsData as JsonData)?.list || []);
|
||||
} catch (error) {
|
||||
console.error('Failed to load alert data:', error);
|
||||
} finally {
|
||||
@@ -55,7 +56,7 @@ export function AlertManager() {
|
||||
setRuleDialogOpen(true);
|
||||
};
|
||||
|
||||
const openEditRule = ( rule: any) => {
|
||||
const openEditRule = (rule: JsonData) => {
|
||||
setEditingRule(rule);
|
||||
setRuleDialogOpen(true);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user