nats-io / nats-streaming-server

NATS Streaming System Server
https://nats.io
Apache License 2.0
2.51k stars 283 forks source link

How can we use NATS streaming from node/hemera services? #314

Closed kristianmandrup closed 7 years ago

kristianmandrup commented 7 years ago

We have a hemera service which generates a stream as output and looking to exploit the NATS streaming server. Any examples or docs for this?

Thanks :)

https://github.com/devongovett/node-wkhtmltopdf#usage

// Stream input and output
var stream = wkhtmltopdf(fs.createReadStream('file.html'));

// Optional callback
wkhtmltopdf('http://google.com/', { pageSize: 'letter' }, function (err, stream) {
  // do whatever with the stream
});

Somehow use this stream it with NATS streaming and hemera...

exports.generatePdf = function (opts) {
  hemera.act(pattern.publish, function (err, resp) {
    resp.send({
      opts
    })
  })
}

exports.listenAndStream = function (res) {
  // Subscribe to result from html2pdf generator service
  hemera.add(pattern.subscribe, function (req, cb) {
    console.log('request:', req.stream);
    res.stream(req.stream);
    res.close();
  })
}
kozlovic commented 7 years ago

We have a node streaming client, did you have a look? https://github.com/nats-io/node-nats-streaming

kristianmandrup commented 7 years ago

Great! Didn't notice any reference, but maybe since it is WIP. How long till it is out of incubation? Can it be used now for basic usage? Cheers :)

kozlovic commented 7 years ago

I will let the owner of the repo that he should probably remove the WIP ;-) There are already releases and people have been using it. Of course, any issue that you find, please file a GH issue. Thanks!

kristianmandrup commented 7 years ago

Awesome thanks :)