-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgetStatus.ts
More file actions
55 lines (49 loc) · 1.44 KB
/
getStatus.ts
File metadata and controls
55 lines (49 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { InstanceClientIdConfig } from '@/config/instanceClientConfig';
import { queryOptions } from '@tanstack/react-query';
export interface SystemStatus {
id: 'availability' | 'maintenance' | 'primary' | string;
status: 'Available' | 'Unavailable' | string;
__updatedtime__: number;
__createdtime__: number;
}
const enum ComponentStatusName {
'hdb.http' = 'hdb.http',
'hdb.authentication' = 'hdb.authentication',
'hdb.replication' = 'hdb.replication',
'hdb.logging' = 'hdb.logging',
'hdb.mqtt' = 'hdb.mqtt',
'hdb.operationsApi' = 'hdb.operationsApi',
'status-check.rest' = 'status-check.rest',
'status-check.jsResource' = 'status-check.jsResource',
}
interface ComponentStatus {
name: ComponentStatusName | string;
componentName: ComponentStatusName | string;
status: 'healthy' | string;
lastChecked: {
workers: Record<string, number>;
main: number;
};
}
interface StatusResponse {
systemStatus: SystemStatus[];
restartRequired: boolean;
componentStatus: ComponentStatus[];
[key: string]: unknown;
}
export function getStatusQueryOptions({ entityId, instanceClient }: InstanceClientIdConfig, enabled?: boolean) {
return queryOptions({
queryKey: [entityId, 'get_status'] as const,
staleTime: 9_000,
refetchInterval: 10_000,
retryDelay: 10_000,
throwOnError: false,
enabled,
queryFn: async () => {
const { data } = await instanceClient.post<StatusResponse>('/', {
operation: 'get_status',
});
return data;
},
});
}