Spaces:
Sleeping
Sleeping
File size: 1,487 Bytes
1d7d958 | 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 | import { IWorker, WorkerPlatform, WorkerStatus } from '../types/worker.types';
export class WorkerModel implements IWorker {
public workerId: string;
public workerName: string;
public platform: WorkerPlatform;
public cpu: string;
public ram: string;
public gpu: string;
public tpu: string;
public batchSize: number;
public rowsPerSecond: number;
public lastHeartbeat: string;
public currentTaskId: string | null;
public status: WorkerStatus;
public tasksCompleted: number;
public tasksFailed: number;
public totalRowsProcessed: number;
public connectedAt: string;
constructor(data: Partial<IWorker> & { workerId: string; workerName: string; platform: WorkerPlatform }) {
const now = new Date().toISOString();
this.workerId = data.workerId;
this.workerName = data.workerName;
this.platform = data.platform;
this.cpu = String(data.cpu || 'Unknown');
this.ram = String(data.ram || 'Unknown');
this.gpu = String(data.gpu || 'None');
this.tpu = String(data.tpu || 'None');
this.batchSize = data.batchSize || 32;
this.rowsPerSecond = data.rowsPerSecond || 0;
this.lastHeartbeat = data.lastHeartbeat || now;
this.currentTaskId = data.currentTaskId || null;
this.status = data.status || 'idle';
this.tasksCompleted = data.tasksCompleted || 0;
this.tasksFailed = data.tasksFailed || 0;
this.totalRowsProcessed = data.totalRowsProcessed || 0;
this.connectedAt = data.connectedAt || now;
}
}
|