feat(api): enhance peer session tracking and error handling
CI / changes (push) Successful in 8s
CI / commitlint (push) Has been skipped
CI / openapi (push) Has been skipped
CI / web (push) Successful in 35s
CI / go (push) Successful in 52s
CI / bird2 (push) Successful in 16s
CI / release (push) Successful in 3m58s
CI / changes (push) Successful in 8s
CI / commitlint (push) Has been skipped
CI / openapi (push) Has been skipped
CI / web (push) Successful in 35s
CI / go (push) Successful in 52s
CI / bird2 (push) Successful in 16s
CI / release (push) Successful in 3m58s
- Added `PollError` field to `peerSessionOnSpeaker` and `liveSpeakerPoll` types to capture polling errors for speakers. - Updated `matchPeerOnSpeakers` function to handle polling errors and adjust session state reporting. - Modified frontend components to display polling error messages alongside session states, improving user visibility into peer connection statuses. - Enhanced API response structure to include live speaker polling information, facilitating better monitoring of speaker health.
This commit is contained in:
@@ -156,6 +156,7 @@ export type PeerSessionOnSpeaker = {
|
||||
speaker_id: string;
|
||||
label: string;
|
||||
state: string;
|
||||
poll_error?: string;
|
||||
};
|
||||
|
||||
export type PeerRow = {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { apiMutate } from '$lib/api/client.js';
|
||||
import type { PeerRow, BgpPeerCreate, SpeakerRow } from '$lib/api/types.js';
|
||||
import type { PeerRow, BgpPeerCreate, SpeakerRow, PeerSessionOnSpeaker } from '$lib/api/types.js';
|
||||
import { Badge } from '$lib/ui/core/badge/index.js';
|
||||
import { Button } from '$lib/ui/core/button/index.js';
|
||||
import { Label } from '$lib/ui/core/label/index.js';
|
||||
@@ -77,20 +77,21 @@
|
||||
{ id: 'actions', label: '', class: 'w-20' }
|
||||
] as const;
|
||||
|
||||
function peerNodeLine(s: PeerSessionOnSpeaker): string {
|
||||
if (s.poll_error) return `${s.label}: опрос недоступен`;
|
||||
if (s.state === 'Established') return `${s.label}: Established`;
|
||||
if (s.state === 'absent') return `${s.label}: нет сессии`;
|
||||
return `${s.label}: ${s.state || '—'}`;
|
||||
}
|
||||
|
||||
function peerConnectedLabel(p: PeerRow): string {
|
||||
const nodes = p.session_on_speakers ?? [];
|
||||
if (nodes.length > 0) {
|
||||
return nodes.map(peerNodeLine).join(' · ');
|
||||
}
|
||||
const established = p.established_on_speakers ?? [];
|
||||
if (established.length > 0) {
|
||||
const labels = established.map((s) => s.label).join(', ');
|
||||
return established.length === 1
|
||||
? `Подключён: ${labels}`
|
||||
: `Подключён (${established.length} нод): ${labels}`;
|
||||
}
|
||||
if (p.connected_speaker_label?.trim()) {
|
||||
return `На ноде: ${p.connected_speaker_label.trim()}`;
|
||||
}
|
||||
if (p.session_on_speakers && p.session_on_speakers.length > 0) {
|
||||
const parts = p.session_on_speakers.map((s) => `${s.label} (${s.state})`);
|
||||
return parts.join(', ');
|
||||
return established.map((s) => `${s.label}: Established`).join(' · ');
|
||||
}
|
||||
return 'Не найден на опрошенных нодах';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user