Permalink
Browse files

basic flow works

  • Loading branch information...
1 parent f6d0b8b commit d838074f816bb7c536d489fe3aa9fa4b2016e2e9 @substack committed Apr 21, 2012
Showing with 34 additions and 9 deletions.
  1. +19 −0 bin/cmd.js
  2. +15 −9 index.js
View
@@ -0,0 +1,19 @@
+var zygote = require('../');
+var fs = require('fs');
+
+var argv = require('optimist')
+ .demand('seaport')
+ .argv
+;
+
+var cmd = argv._[0];
+var z = zygote(argv.seaport);
+
+if (cmd === 'drone') {
+ z.drone(argv);
+}
+else if (cmd === 'push') {
+ var planFile = argv._[1];
+ var plan = JSON.parse(fs.readFileSync(planFile));
+ z.push(plan);
+}
View
@@ -1,13 +1,14 @@
var airport = require('airport');
var seaport = require('seaport');
+var dnode = require('dnode');
var marx = require('marx');
module.exports = function (ports) {
var isSeaport = ports && typeof ports === 'object'
&& ports.free && ports.assume && ports.allocate
;
- if (!isSeaport) ports = seaport(ports);
+ if (!isSeaport) ports = seaport.connect(ports);
var air = airport(ports);
return {
@@ -28,26 +29,31 @@ module.exports = function (ports) {
return acc;
}, {});
+ var workers = ps.reduce(function (acc, p) {
+ acc[p.id] = 10;
+ return acc;
+ }, {});
+
ps.forEach(function (p) {
- var c = dnode.connect(p, function (remote, conn) {
- remote.plan(plan, ids);
- });
- c.on('error', function (err) {
- console.error(err);
+ dnode.connect(p, function (remote, conn) {
+ remote.plan(workers, plan);
+ conn.end();
});
});
+
+ ports.close();
});
},
};
};
function drone (ports, plan) {
- if (!plan) plan = {};
+ if (!plan) prevPlan = {};
var service = function (remote, conn) {
- this.plan = function (p, workers) {
+ this.plan = function (workers, plan) {
// todo: query zygote roles at the start and subscribe to update
- plan = p;
+ prevPlan = plan;
var work = marx(workers, plan)[id] || {};
console.dir(work);

0 comments on commit d838074

Please sign in to comment.