fix(netflow): починить live-аналитику и снизить запись в PostgreSQL
Docker images / prepare-release (push) Successful in 11s
Docker images / backend-test (push) Successful in 2m9s
Docker images / frontend-image (push) Successful in 3m20s
Docker images / updater-image (push) Successful in 49s
Docker images / backend-image (push) Successful in 2m44s
Docker images / notify-webhook (push) Skipped
Docker images / publish-release (push) Successful in 10s
Docker images / prepare-release (push) Successful in 11s
Docker images / backend-test (push) Successful in 2m9s
Docker images / frontend-image (push) Successful in 3m20s
Docker images / updater-image (push) Successful in 49s
Docker images / backend-image (push) Successful in 2m44s
Docker images / notify-webhook (push) Skipped
Docker images / publish-release (push) Successful in 10s
Коллектор снова отдаёт назначения в живом потоке. Ошибки записи видны в статусе, лишние перезаписи минутных агрегатов убраны. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
+11
-1
@@ -15,6 +15,12 @@ function parseSseBlock(block: string): { event: string; data: string } {
|
||||
return { event, data: dataLines.join("\n") }
|
||||
}
|
||||
|
||||
export function isValidFlowLiveSample(value: unknown): value is FlowAnalyticsDto {
|
||||
if (!value || typeof value !== "object") return false
|
||||
const v = value as Partial<FlowAnalyticsDto>
|
||||
return typeof v.uniqueSrc === "number" && Array.isArray(v.destinations)
|
||||
}
|
||||
|
||||
export function useFlowLive(opts: {
|
||||
enabled: boolean
|
||||
backendUrl: string
|
||||
@@ -75,7 +81,11 @@ export function useFlowLive(opts: {
|
||||
if (!raw.trim() || raw.trim().startsWith(":")) continue
|
||||
const ev = parseSseBlock(raw)
|
||||
if (ev.event === "sample" && ev.data) {
|
||||
const parsed = JSON.parse(ev.data) as FlowAnalyticsDto
|
||||
const parsed = JSON.parse(ev.data) as unknown
|
||||
if (!isValidFlowLiveSample(parsed)) {
|
||||
setError("live sample пустой")
|
||||
continue
|
||||
}
|
||||
setSample(parsed)
|
||||
setError(parsed.degraded ? "Коллектор перегружен: упрощённая аналитика" : null)
|
||||
} else if (ev.event === "error" && ev.data) {
|
||||
|
||||
Reference in New Issue
Block a user