// var dnode = require('dnode');
var dservice = require('dservice');
// var server = dnode({
var server = dservice('d1', {
transform: function (s, cb) {
cb(s.replace(/[aeiou]{2,}/, 'oo').toUpperCase());
}
});
// server.listen(5004);
server.start();
and its client
var dservice = require('dservice');
var service = dservice();
service.dnodeFor('d1', function (err, remote, d) {
remote.transform('beep', function (s) {
console.log('beep => ' + s);
d.end();
});
});
Remote dependencies
var dservice = require('dservice');
var server = dservice('d2', {
jsconf: function (cb) {
server.dnodeFor('d1', function (err, remote, d) {
remote.transform('rulez', cb);
});
}
});
server.rely('d1');
server.start();
[WiP]
Cycle detection
Multiple engines
package.json hack: RemoteDependency
Streams vs Transactions
Streams are composable, awesome, etc
Don't solve all the problems
You will buffer
Sometimes you have to repeat operations
Transactional behaviour
I want repeatable operations
I want durability
and I specially want Sugar[TM]
How it works?
user implements idempotent steps
serialize your command
1 input + 2 working queue per step
handles timeouts and retries
Implementing a step
var dns = require('dns');
function MyResolveStep(logger, pipeline) {
var self = this;
self.input_queue = 'my_input_queue';
self.execute = function (payload, done) {
dns.resolve(payload.data.address, function (err, addresses) {
done(err, addresses, err ? 'my_resolved_addr_q' : 'my_error_q');
});
};
return self;
}
module.exports = MyResolveStep;