I am implementing an addon in node.js where there is a continuous in flow
of data from another application to this addon module.
This addon modules parses the data, populates the data into V8 data
structures and calls the callback of node.js application.
Everything works fine till here.
On top this I'm planning to implement a Readable stream, and this is the
code for readable stream.
var addon = require('../build/Release/addon');
var inherits = require('util').inherits;
var Readable = require('stream').Readable;
var util = require('util');
module.exports = MyReadableStream;
function MyReadableStream(opts) {
if(!(this instanceof MyReadableStream)) {
return new MyReadableStream(opts);
}
this.addonFunc = addon.DataSource;
Readable.call(this, opts);
}
inherits( MyReadableStream, Readable);
MyReadableStream.prototype._read = function( ) {
var self = this;
this.addonFunc(function(data) {
var ret = self.push(JSON.stringify(record, null, ' '));
}, function(error) {
self.push(err);
}, function(end) {
self.push(null);
});
}
This is the streamReader implementation on top of my addon.
When I bypass the stream reader and consume data directly in the the
node.js application, it exits gracefully, but when I read the data using
this streamReader
and read in the application using something like
var stream = new MyReadableStream(opts);
stream.on('data', callback)
stream.on('error', callback2)
stream.on('end', callback3)
The node.js application never exits and runs indefinitely.
Any help or suggestions would help me move forward.
Thanks
Gayathri
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/786f15a8-0d94-4cb2-ba7a-719ffff98e61%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.