feat: add resource monitoring and provider upgrade
This commit is contained in:
@@ -18,6 +18,81 @@ export interface ProviderHeartbeatMessage {
|
||||
at: string;
|
||||
}
|
||||
|
||||
export interface SystemStatusSnapshot {
|
||||
ok: boolean;
|
||||
collectedAt: string;
|
||||
cpu: Record<string, JsonValue>;
|
||||
memory: Record<string, JsonValue>;
|
||||
disk: Record<string, JsonValue>;
|
||||
errors: JsonValue[];
|
||||
}
|
||||
|
||||
export interface ProviderSystemStatusMessage {
|
||||
type: "system_status";
|
||||
providerId: string;
|
||||
at: string;
|
||||
status: SystemStatusSnapshot;
|
||||
}
|
||||
|
||||
export interface DockerContainerSummary {
|
||||
id: string;
|
||||
name: string;
|
||||
image: string;
|
||||
state: string;
|
||||
status: string;
|
||||
ports: string;
|
||||
createdAt: string;
|
||||
runningFor: string;
|
||||
size: string;
|
||||
networks: string;
|
||||
}
|
||||
|
||||
export interface DockerImageSummary {
|
||||
id: string;
|
||||
repository: string;
|
||||
tag: string;
|
||||
size: string;
|
||||
createdSince: string;
|
||||
containers: string;
|
||||
}
|
||||
|
||||
export interface DockerVolumeSummary {
|
||||
name: string;
|
||||
driver: string;
|
||||
scope: string;
|
||||
mountpoint: string;
|
||||
}
|
||||
|
||||
export interface DockerNetworkSummary {
|
||||
id: string;
|
||||
name: string;
|
||||
driver: string;
|
||||
scope: string;
|
||||
internal: string;
|
||||
ipv4: string;
|
||||
ipv6: string;
|
||||
}
|
||||
|
||||
export interface DockerStatusSnapshot {
|
||||
ok: boolean;
|
||||
socketPresent: boolean;
|
||||
collectedAt: string;
|
||||
daemon: Record<string, JsonValue>;
|
||||
counts: Record<string, JsonValue>;
|
||||
containers: DockerContainerSummary[];
|
||||
images: DockerImageSummary[];
|
||||
volumes: DockerVolumeSummary[];
|
||||
networks: DockerNetworkSummary[];
|
||||
errors: JsonValue[];
|
||||
}
|
||||
|
||||
export interface ProviderDockerStatusMessage {
|
||||
type: "docker_status";
|
||||
providerId: string;
|
||||
at: string;
|
||||
status: DockerStatusSnapshot;
|
||||
}
|
||||
|
||||
export interface ProviderTaskStatusMessage {
|
||||
type: "task_status";
|
||||
providerId: string;
|
||||
@@ -31,7 +106,7 @@ export interface ProviderTaskStatusMessage {
|
||||
export interface CoreDispatchMessage {
|
||||
type: "dispatch";
|
||||
taskId: string;
|
||||
command: "docker.ps" | "echo";
|
||||
command: "docker.ps" | "provider.upgrade" | "echo";
|
||||
payload: Record<string, JsonValue>;
|
||||
}
|
||||
|
||||
@@ -45,6 +120,8 @@ export interface CoreAcknowledgeMessage {
|
||||
export type ProviderToCoreMessage =
|
||||
| ProviderRegisterMessage
|
||||
| ProviderHeartbeatMessage
|
||||
| ProviderSystemStatusMessage
|
||||
| ProviderDockerStatusMessage
|
||||
| ProviderTaskStatusMessage;
|
||||
|
||||
export type CoreToProviderMessage = CoreDispatchMessage | CoreAcknowledgeMessage;
|
||||
@@ -58,6 +135,23 @@ export interface ApiNode {
|
||||
lastHeartbeat: string | null;
|
||||
}
|
||||
|
||||
export interface ApiNodeDockerStatus {
|
||||
providerId: string;
|
||||
name: string;
|
||||
nodeStatus: "online" | "offline";
|
||||
dockerStatus: JsonValue | null;
|
||||
updatedAt: string | null;
|
||||
}
|
||||
|
||||
export interface ApiNodeSystemStatus {
|
||||
providerId: string;
|
||||
name: string;
|
||||
nodeStatus: "online" | "offline";
|
||||
current: JsonValue | null;
|
||||
history: JsonValue[];
|
||||
updatedAt: string | null;
|
||||
}
|
||||
|
||||
export interface ApiTask {
|
||||
id: string;
|
||||
providerId: string;
|
||||
@@ -97,7 +191,7 @@ export function isProviderToCoreMessage(value: unknown): value is ProviderToCore
|
||||
if (typeof value !== "object" || value === null || !("type" in value)) return false;
|
||||
const msg = value as { type?: unknown; providerId?: unknown };
|
||||
return (
|
||||
(msg.type === "register" || msg.type === "heartbeat" || msg.type === "task_status") &&
|
||||
(msg.type === "register" || msg.type === "heartbeat" || msg.type === "system_status" || msg.type === "docker_status" || msg.type === "task_status") &&
|
||||
typeof msg.providerId === "string" &&
|
||||
msg.providerId.length > 0
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user