Upgrade @cameleer/design-system to ^0.1.3 which adds LIVE/PAUSED toggle to TopBar backed by autoRefresh state in GlobalFilterProvider. Add useRefreshInterval() hook that returns the polling interval when auto-refresh is on, or false when paused. Wire it into all query hooks that use refetchInterval (executions, catalog, agents, metrics, admin database/opensearch). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
28 lines
994 B
TypeScript
28 lines
994 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import { config } from '../../config';
|
|
import { useAuthStore } from '../../auth/auth-store';
|
|
import { useRefreshInterval } from './use-refresh-interval';
|
|
|
|
export function useProcessorMetrics(routeId: string | null, appId?: string) {
|
|
const refetchInterval = useRefreshInterval(30_000);
|
|
return useQuery({
|
|
queryKey: ['processor-metrics', routeId, appId],
|
|
queryFn: async () => {
|
|
const token = useAuthStore.getState().accessToken;
|
|
const params = new URLSearchParams();
|
|
if (routeId) params.set('routeId', routeId);
|
|
if (appId) params.set('appId', appId);
|
|
const res = await fetch(`${config.apiBaseUrl}/routes/metrics/processors?${params}`, {
|
|
headers: {
|
|
Authorization: `Bearer ${token}`,
|
|
'X-Cameleer-Protocol-Version': '1',
|
|
},
|
|
});
|
|
if (!res.ok) throw new Error(`${res.status}`);
|
|
return res.json();
|
|
},
|
|
enabled: !!routeId,
|
|
refetchInterval,
|
|
});
|
|
}
|