moving runnerMap to Runner class
This commit is contained in:
parent
c5e75967d9
commit
4b6aacb769
@ -10,6 +10,22 @@ var Runner = (function(){
|
|||||||
var proto = {};
|
var proto = {};
|
||||||
var __empty = function(){};
|
var __empty = function(){};
|
||||||
|
|
||||||
|
proto.runnerMap = {};
|
||||||
|
|
||||||
|
proto.cleanUp = function(label){
|
||||||
|
delete proto.runnerMap[label];
|
||||||
|
};
|
||||||
|
|
||||||
|
proto.set = function(runner){
|
||||||
|
proto.runnerMap[runner.label] = runner;
|
||||||
|
proto.runnerMap[runner.label] = runner;
|
||||||
|
};
|
||||||
|
|
||||||
|
proto.get = function(label){
|
||||||
|
return proto.runnerMap[label];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
proto.create = function(config){
|
proto.create = function(config){
|
||||||
var runner = Object.create(proto);
|
var runner = Object.create(proto);
|
||||||
Object.assign(runner, config);
|
Object.assign(runner, config);
|
||||||
@ -189,27 +205,16 @@ var WorkerCollection = (function(){
|
|||||||
// about 3 minutes to create a worker.
|
// about 3 minutes to create a worker.
|
||||||
workers.currentCreating = 0;
|
workers.currentCreating = 0;
|
||||||
|
|
||||||
//**************************************************
|
// REMOVE THIS
|
||||||
//**************************************************
|
worker.runnerMap = Runner.runnerMap;
|
||||||
// TODO: Move to Runners
|
|
||||||
workers.runnerMap = {};
|
|
||||||
|
|
||||||
workers.__runnerCleanUp = function(label){
|
|
||||||
delete workers.runnerMap[label];
|
|
||||||
};
|
|
||||||
|
|
||||||
workers.setRunner = function(runner){
|
workers.setRunner = function(runner){
|
||||||
workers.runnerMap[runner.label] = runner;
|
Runner.set(runner);
|
||||||
var __empty = runner.cleanUp;
|
|
||||||
runner.cleanUp = function(){
|
|
||||||
workers.__runnerCleanUp(runner.label);
|
|
||||||
runner.cleanUp = __empty;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
workers.getRunner = function(label){
|
workers.getRunner = function(label){
|
||||||
return workers.runnerMap[label];
|
return Runner.get(label);
|
||||||
};
|
};
|
||||||
|
|
||||||
//**************************************************
|
//**************************************************
|
||||||
@ -316,6 +321,7 @@ var WorkerCollection = (function(){
|
|||||||
// TODO: move to seperate method
|
// TODO: move to seperate method
|
||||||
doapi.dropletsByTag(tag, function(data){
|
doapi.dropletsByTag(tag, function(data){
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
|
console.log(data);
|
||||||
console.log(`Deleting ${data['droplets'].length} workers tagged ${tag}. Workers`,
|
console.log(`Deleting ${data['droplets'].length} workers tagged ${tag}. Workers`,
|
||||||
data['droplets'].map(function(item){
|
data['droplets'].map(function(item){
|
||||||
return item.name+' | '+item.id;
|
return item.name+' | '+item.id;
|
||||||
|
@ -45,7 +45,12 @@ sleep(${sleepTime})
|
|||||||
body = JSON.parse(body);
|
body = JSON.parse(body);
|
||||||
res = (Buffer.from(body.res, 'base64').toString('ascii'));
|
res = (Buffer.from(body.res, 'base64').toString('ascii'));
|
||||||
}
|
}
|
||||||
console.log(`${id} with results ${res}. Errors ${errors}. No runner ${noRunner}. Completed ${completed}`);
|
console.log(`
|
||||||
|
${id} with results ${res}.
|
||||||
|
Errors ${errors}.
|
||||||
|
No runner ${noRunner}.
|
||||||
|
Completed ${completed}
|
||||||
|
`);
|
||||||
|
|
||||||
callback()
|
callback()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user