THRIFT-1659 Bring nodejs default transport in line with Java default transport
diff --git a/lib/nodejs/lib/thrift/connection.js b/lib/nodejs/lib/thrift/connection.js
index 05c5a6c..a49d427 100644
--- a/lib/nodejs/lib/thrift/connection.js
+++ b/lib/nodejs/lib/thrift/connection.js
@@ -30,7 +30,7 @@
this.connection = stream;
this.options = options || {};
- this.transport = this.options.transport || ttransport.TFramedTransport;
+ this.transport = this.options.transport || ttransport.TBufferedTransport;
this.protocol = this.options.protocol || tprotocol.TBinaryProtocol;
this.offline_queue = [];
this.connected = false;
@@ -135,43 +135,39 @@
var child_process = require('child_process');
var StdIOConnection = exports.StdIOConnection = function(command, options) {
- var command_parts = command.split(' ');
- command = command_parts[0];
- var args = command_parts.splice(1,command_parts.length -1);
- var child = this.child = child_process.spawn(command,args);
+ var command_parts = command.split(' ');
+ command = command_parts[0];
+ var args = command_parts.splice(1,command_parts.length -1);
+ var child = this.child = child_process.spawn(command,args);
var self = this;
EventEmitter.call(this);
- this._debug = options.debug || false;
+ this._debug = options.debug || false;
this.connection = child.stdin;
this.options = options || {};
- this.transport = this.options.transport || ttransport.TFramedTransport;
+ this.transport = this.options.transport || ttransport.TBufferedTransport;
this.protocol = this.options.protocol || tprotocol.TBinaryProtocol;
this.offline_queue = [];
- if(this._debug === true){
+ if(this._debug === true){
+ this.child.stderr.on('data',function(err){
+ console.log(err.toString(),'CHILD ERROR');
+ });
- this.child.stderr.on('data',function(err){
- console.log(err.toString(),'CHILD ERROR');
+ this.child.on('exit',function(code,signal){
+ console.log(code+':'+signal,'CHILD EXITED');
+ });
+ }
- });
+ this.frameLeft = 0;
+ this.framePos = 0;
+ this.frame = null;
+ this.connected = true;
- this.child.on('exit',function(code,signal){
- console.log(code+':'+signal,'CHILD EXITED');
-
- });
-
- }
-
- this.frameLeft = 0;
- this.framePos = 0;
- this.frame = null;
- this.connected = true;
-
- self.offline_queue.forEach(function(data) {
- self.connection.write(data);
- });
+ self.offline_queue.forEach(function(data) {
+ self.connection.write(data);
+ });
this.connection.addListener("error", function(err) {
@@ -226,7 +222,7 @@
this.connection.write(data);
}
exports.createStdIOConnection = function(command,options){
- return new StdIOConnection(command,options);
+ return new StdIOConnection(command,options);
};
@@ -236,8 +232,8 @@
}
var client = new cls(new connection.transport(undefined, function(buf) {
- connection.write(buf);
- }), connection.protocol);
+ connection.write(buf);
+ }), connection.protocol);
// TODO clean this up
connection.client = client;
diff --git a/lib/nodejs/lib/thrift/server.js b/lib/nodejs/lib/thrift/server.js
index a17419b..f219048 100644
--- a/lib/nodejs/lib/thrift/server.js
+++ b/lib/nodejs/lib/thrift/server.js
@@ -26,7 +26,7 @@
cls = cls.Processor;
}
var processor = new cls(handler);
- var transport = (options && options.transport) ? options.transport : ttransport.TFramedTransport;
+ var transport = (options && options.transport) ? options.transport : ttransport.TBufferedTransport;
var protocol = (options && options.protocol) ? options.protocol : TBinaryProtocol;
return net.createServer(function(stream) {
diff --git a/test/nodejs/Makefile.am b/test/nodejs/Makefile.am
index 2c0a18f..7668039 100755
--- a/test/nodejs/Makefile.am
+++ b/test/nodejs/Makefile.am
@@ -35,8 +35,8 @@
clean-local:
$(RM) -r gen-nodejs
-server: stubs
+server:
NODE_PATH=../../lib/nodejs/lib:../../lib/nodejs/lib/thrift:$(NODE_PATH) node server.js
-client: stubs
+client:
NODE_PATH=../../lib/nodejs/lib:../../lib/nodejs/lib/thrift:$(NODE_PATH) node client.js
diff --git a/test/nodejs/client.js b/test/nodejs/client.js
index ea2cc38..269aab3 100644
--- a/test/nodejs/client.js
+++ b/test/nodejs/client.js
@@ -23,7 +23,7 @@
var ThriftTest = require('./gen-nodejs/ThriftTest'),
ttypes = require('./gen-nodejs/ThriftTest_types');
-//var connection = thrift.createConnection('localhost', 9090, { 'transport': ttransport.TBufferedTransport }),
+//var connection = thrift.createConnection('localhost', 9090, { 'transport': ttransport.TFramedTransport }),
var connection = thrift.createConnection('localhost', 9090),
client = thrift.createClient(ThriftTest, connection);