skywalking-backend-js-netease
Version:
The NodeJS agent for Apache SkyWalking
41 lines • 1.45 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.execute = exports.initCommandExecutor = void 0;
const CommandCache_1 = require("./CommandCache");
const CommandConfigReset_1 = require("./CommandConfigReset");
const CommandProfileDump_1 = require("./CommandProfileDump");
// cache put cmd
const cache = new CommandCache_1.CmdSerialNumCache(64);
const executor = new Map();
executor.set('ConfigReset', new CommandConfigReset_1.CommandReset());
executor.set('ProfileDump', new CommandProfileDump_1.CommandProfileDump());
function initCommandExecutor() {
executor.forEach(e => e.start());
}
exports.initCommandExecutor = initCommandExecutor;
function execute(cmd) {
const cmds = cmd === null || cmd === void 0 ? void 0 : cmd.getCommandsList();
if (!cmds || cmds.length == 0) {
return;
}
cmds.forEach(c => {
var _a;
if (!executor.has(c.getCommand())) {
return;
}
// serial number
let args = c.getArgsList() || [];
args = args.filter(x => x.getKey() == "SerialNumber");
if (args.length === 0) {
return;
}
if (cache.contain(args[0].getValue())) {
return;
}
(_a = executor.get(c.getCommand())) === null || _a === void 0 ? void 0 : _a.execute(c);
cache.add(args[0].getValue());
});
}
exports.execute = execute;
;
//# sourceMappingURL=CommandExecute.js.map