UNPKG

@ultipa-graph/ultipa-driver

Version:

NodeJS SDK for ultipa-server 5.2

122 lines 3.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.JobExra = void 0; const connection_base_1 = require("./connection.base"); const utils_1 = require("../../utils"); const CommandList = utils_1.UQLMAKER.CommandList; class JobExra extends connection_base_1.ConnectionBase { /** * Show all job,if have id,return job */ async showJob(id, config) { let command = CommandList.showJob; let params = null; if (id == "*") { params = null; } else { params = []; if (id) { params.push(id); } } let uqlMaker = new utils_1.UQLMAKER(command, config, params); let res = await this.uql(uqlMaker.toString(), config); return res.items["_job"].asJobs(); } /** * Clean job by id */ async clearJob(id, config) { let command = CommandList.clearJob; let params = null; if (!id) { id = "*"; } if (id == "*") { params = ["*"]; } else { params = []; if (id) { params.push(id); } } let uqlMaker = new utils_1.UQLMAKER(command, config, params); return this.uql(uqlMaker.toString(), config); } /** * pause job by id */ async pauseJob(id, config) { let command = CommandList.pauseJob; let params = []; if (id == "*") { params.push("*"); } if (id) { params.push(id); } let uqlMaker = new utils_1.UQLMAKER(command, config, params); return this.uql(uqlMaker.toString(), config); } /** * resume job by id */ async resumeJob(id, config) { let command = CommandList.resumeJob; let params = []; if (id == "*") { params.push("*"); } if (id) { params.push(id); } let uqlMaker = new utils_1.UQLMAKER(command, config, params); return this.uql(uqlMaker.toString(), config); } /** * stop job by id */ async stopJob(id, config) { let command = CommandList.stopJob; let params = []; if (id == "*") { params.push("*"); } if (id) { params.push(id); } let uqlMaker = new utils_1.UQLMAKER(command, config, params); return this.uql(uqlMaker.toString(), config); } /** * Retrieves all running and stopping processes from the instance. */ async top(config) { let command = CommandList.top; let uqlMaker = new utils_1.UQLMAKER(command, config); let res = await this.uql(uqlMaker.toString(), config); return res.items["_top"]?.asProcesses() || []; } /** * Kills running processes in the instance. If no process id is specified, all processes will be killed. */ async kill(processId, config) { let command = CommandList.kill; let params = []; if (processId == "*") { params = ["*"]; } else if (processId) { params = [processId]; } else { params = ["*"]; } let uqlMaker = new utils_1.UQLMAKER(command, config, params); return this.uql(uqlMaker.toString(), config); } } exports.JobExra = JobExra; //# sourceMappingURL=job.extra.js.map