prdn / zmq-omdp

ZMQ-OMDP : ZeroMQ Obsessive Majordomo Protocol - microservices framework for NodeJS - reliable and extensible service-oriented request-reply
https://fincluster.com
20 stars 7 forks source link

zmq-omdp

!!!!! DEPRECATED REPOSITORY !!!!! PLEASE SWITCH TO PIGATO

ZeroMQ Obsessive Majordomo Protocol: microservices framework for NodeJS - reliable and extensible service-oriented request-reply inspired by ZeroMQ Majordomo Protocol (MDP) v0.2.

Structure

API

omdp.Worker(socket_str, service_name)

Worker receives "request" events that contain 2 arguments:

reply writable stream exposes also following methods:

worker.on('request', function(data, reply) {
  fs.createReadStream(data).pipe(reply);
});

// or
worker.on('request', function(data, reply) {
    for (var i = 0; i < 1000; i++) {
      res.write('PARTIAL DATA ' + i);
    }
    res.end('FINAL DATA');
});

Take note: due to the framing protocol of zmq only the data supplied to response.end(data) will be given to the client's final callback.

omdp.Client(socket_str)

Clients may make simple requests using client.request(...) with 5 arguments.

client.request('echo', 'data', function (data) {
  // frames sent prior to final frame
  console.log('partial data', data);
}, function (err, data) {
  // this is the final frame sent
  console.log('final data', data);
}, { timeout: 5000 });

Clients may also make streaming request using client.requestStream() with 3 arguments.

client.requestStream('echo', 'data', { timeout: -1 }).pipe(process.stdout);
Request options

omdp.Broker(socket_str)

Simply starts up a broker.

Take note: when using a inproc socket the broker must become active before any queued messages.

Protocol

Benefits

Features

Specification (good for RFC)

Roadmap

Follow me

Credits

Based on https://github.com/nuh-temp/zmq-mdp2 project