Skip to content

Commit

Permalink
ready to support a cloudd cli
Browse files Browse the repository at this point in the history
  • Loading branch information
openmason committed Dec 26, 2012
1 parent 797c7aa commit cec1b19
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
3 changes: 0 additions & 3 deletions lib/cloudd.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ winston.default.transports.console.colorize = true;
winston.default.transports.console.timestamp = true;

// -------- todo -------------
// for now no graph is built, later we'll check for DAG
// preconditions to trigger next job etc.,
// http://www.graphdracula.net/, node-graph

// cloudd-format - create new package for formatting job names
// -- use date format, use host name, etc.,
Expand Down
7 changes: 7 additions & 0 deletions lib/dag.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ DAG.prototype.nextTask = function() {
return t;
};

/*
* progress % in numbers - this is approx value
*/
DAG.prototype.progress = function() {
return this.index<0?0:this.index>this.tasks.length?100:this.index / this.tasks.length;
};

/*
* Set the index to next
*/
Expand Down
16 changes: 16 additions & 0 deletions lib/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ Job.prototype.fetch = function() {
return t;
};

/*
* toString - return key attributes for display purposes
*/
Job.prototype.toStringObj = function() {
return {
id:this.id, name:this.name, description:this.description,
next:this.dag.nextTask(),
progress:this.dag.progress()
};
};

// ----------------
var JobList = function() {
Expand Down Expand Up @@ -154,6 +164,12 @@ JobList.prototype.process = function() {
}
};

/*
* return jobs - displayable parts
*/
JobList.prototype.toStringObj = function() {
return _.map(this.jobs, function(job) { return job.toStringObj(); });
};

// module exports
exports.Job = Job;
Expand Down
5 changes: 5 additions & 0 deletions lib/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ TaskQ.prototype.add = function(task) {
this.q.enqueue(task);
};

// return q as array
TaskQ.prototype.qAsArray = function () {
return this.q.list.toArray();
};

// process the next available Task
// - return the task in done callback
//
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"winston" : ">= 0.6.2",
"sprintf" : ">= 0.1.1",
"to" : ">= 0.2.9",
"cron" : ">= 1.0.1"
"cron" : ">= 1.0.1",
"zmq" : ">= 2.2.0"
},
"devDependencies": {
"mocha" : ">= 1.7.4",
Expand Down

0 comments on commit cec1b19

Please sign in to comment.