feat add connections management and health summary improvements

This commit is contained in:
2026-03-15 16:40:43 +03:00
parent eba0fab091
commit 027d17f193
17 changed files with 8521 additions and 10819 deletions

View File

@@ -28,25 +28,41 @@ function createHealthStore() {
loading: false,
lastUpdated: null
});
let inflightRefresh = null;
let inflightEnvironmentId = null;
/**
* Refresh health summary from API
* @param {string|null} environmentId - Optional environment filter
*/
async function refresh(environmentId = null) {
update(s => ({ ...s, loading: true }));
try {
console.log(`[HealthStore][Action] Refreshing health summary context={{'environmentId': '${environmentId}'}}`);
const summary = await api.getHealthSummary(environmentId);
set({
...summary,
loading: false,
lastUpdated: new Date()
});
} catch (error) {
console.error('[HealthStore][Coherence:Failed] Failed to fetch health summary:', error);
update(s => ({ ...s, loading: false }));
const normalizedEnvironmentId = environmentId || null;
if (inflightRefresh && inflightEnvironmentId === normalizedEnvironmentId) {
return inflightRefresh;
}
update(s => ({ ...s, loading: true }));
inflightEnvironmentId = normalizedEnvironmentId;
inflightRefresh = (async () => {
try {
console.log(`[HealthStore][Action] Refreshing health summary context={{'environmentId': '${environmentId}'}}`);
const summary = await api.getHealthSummary(environmentId);
set({
...summary,
loading: false,
lastUpdated: new Date()
});
return summary;
} catch (error) {
console.error('[HealthStore][Coherence:Failed] Failed to fetch health summary:', error);
update(s => ({ ...s, loading: false }));
throw error;
} finally {
inflightRefresh = null;
inflightEnvironmentId = null;
}
})();
return inflightRefresh;
}
return {
@@ -63,4 +79,4 @@ export const healthStore = createHealthStore();
*/
export const failingCount = derived(healthStore, $health => $health.fail_count);
// [/DEF:health_store:Store]
// [/DEF:health_store:Store]