Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051import { IServiceManager, ServiceHealth, ServiceHealthStatus } from './service-manager';
export interface VmEntry { id: string; name: string; type: string; status: ServiceHealthStatus; createdAt: string; details?: any;}
export class VmRegistry { private createdAt = new Date().toISOString();
constructor(private serviceManager: IServiceManager) {}
async list(): Promise<VmEntry[]> { const services = this.serviceManager.getAll(); const entries: VmEntry[] = [];
for (const service of services) { const health = await service.health().catch((): ServiceHealth => ({ status: 'error' })); entries.push({ id: service.name, name: service.name, type: service.type, status: health.status, createdAt: this.createdAt, details: health.details, }); }
return entries; }
async get(id: string): Promise<VmEntry | undefined> { const service = this.serviceManager.get(id); if (!service) return undefined;
const health = await service.health().catch((): ServiceHealth => ({ status: 'error' })); return { id: service.name, name: service.name, type: service.type, status: health.status, createdAt: this.createdAt, details: health.details, }; }}